Adding some more judges, here and there.
[and.git] / NEERC / headshot / headshot_dk.java
blobc2eafc12e4a1a810fcbb7792043ccba03253a3f1
1 import java.util.*;
2 import java.io.FileNotFoundException;
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.PrintWriter;
7 /**
8 * @author Denis Kuznetsov
9 */
10 public class headshot_dk {
12 public static void main(String[] args) throws IOException {
13 new headshot_dk().go();
16 void go() throws IOException {
17 Scanner in = new Scanner(new File("headshot.in"));
18 ArrayList<Integer> shots = new ArrayList<Integer>();
20 int n = 0;
21 int blanks = 0;
22 while (in.hasNextInt()) {
23 int shot = in.nextInt();
24 shots.add(shot);
25 n++;
26 if (shot == 0) {
27 blanks ++;
31 int twoBlanksInRow = 0;
32 //Copy first element to the end, so it is easier to calculate # of "0 0" subsequence
33 shots.add(shots.get(0));
34 for (int i = 0; i < shots.size() - 1; i++) {
35 if (shots.get(i) == 0) {
36 if (shots.get(i + 1) == 0) {
37 twoBlanksInRow ++;
42 // chance if rotate = # of blanks / # of shots.
43 // chance if shot = # of two blanks in row / # of blanks.
45 int diff = blanks * blanks - twoBlanksInRow * n;
46 PrintWriter out = new PrintWriter("headshot.out");
47 // PrintWriter out = new PrintWriter(System.out);
48 if (diff == 0) {
49 out.println("EQUAL");
50 } else if (diff > 0) {
51 out.println("ROTATE");
52 } else {
53 out.println("SHOOT");
55 out.flush();
56 out.close();