Adding some more judges, here and there.
[and.git] / NEERC / headshot / headshot_petr.java
blobc46efb4fd55f68b6b17612a8b0b6d25573001ff6
1 import java.io.BufferedReader;
2 import java.io.FileReader;
3 import java.io.PrintWriter;
4 import java.io.IOException;
5 import java.util.StringTokenizer;
7 public class headshot_petr implements Runnable {
8 private void solve() throws IOException {
9 String s = nextToken();
10 int n = s.length();
11 int[] a = new int[n];
12 for (int i = 0; i < n; ++i) {
13 a[i] = s.charAt(i) - '0';
15 double p1 = 0;
16 int q1 = 0;
17 double p2 = 0;
18 int q2 = 0;
19 for (int i = 0; i < n; ++i) {
20 if (a[i] == 0) {
21 ++p2;
22 if (a[(i + 1) % n] == 0) {
23 ++p1;
25 ++q1;
27 ++q2;
29 if (p1 / q1 > p2 / q2)
30 writer.println("SHOOT");
31 else if (p1 / q1 < p2 / q2)
32 writer.println("ROTATE");
33 else
34 writer.println("EQUAL");
38 public static void main(String[] args) throws InterruptedException {
39 Thread thread = new Thread(new headshot_petr());
40 thread.start();
41 thread.join();
44 static final String TASK_ID = "headshot";
45 static final String IN_FILE = TASK_ID + ".in";
46 static final String OUT_FILE = TASK_ID + ".out";
47 BufferedReader reader;
48 StringTokenizer tokenizer;
49 PrintWriter writer;
51 public void run() {
52 try {
53 reader = new BufferedReader(new FileReader(IN_FILE));
54 tokenizer = null;
55 writer = new PrintWriter(OUT_FILE);
56 solve();
57 reader.close();
58 writer.close();
59 } catch (Exception e) {
60 e.printStackTrace();
61 System.exit(1);
65 int nextInt() throws IOException {
66 return Integer.parseInt(nextToken());
69 long nextLong() throws IOException {
70 return Long.parseLong(nextToken());
73 double nextDouble() throws IOException {
74 return Double.parseDouble(nextToken());
77 String nextToken() throws IOException {
78 while (tokenizer == null || !tokenizer.hasMoreTokens()) {
79 tokenizer = new StringTokenizer(reader.readLine());
81 return tokenizer.nextToken();