Adding some more judges, here and there.
[and.git] / NEERC / headshot / headshot_mb.java
blobb7cd233a89cb242e951e2ab03acceca75ed781f0
1 import java.io.FileReader;
2 import java.io.IOException;
3 import java.io.PrintWriter;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.Scanner;
8 public class headshot_mb implements Runnable {
9 private Scanner in;
10 private PrintWriter out;
12 public static void main(String[] args) {
13 new Thread(new headshot_mb()).start();
16 public void run() {
17 try {
18 in = new Scanner(new FileReader("headshot.in"));
19 out = new PrintWriter("headshot.out");
21 solve();
23 in.close();
24 out.close();
25 } catch (IOException e) {
26 e.printStackTrace();
30 private void solve() {
31 final ArrayList<Integer> chambers = new ArrayList<Integer>();
32 int numLoaded = 0;
33 int total = 0;
34 final String line = in.nextLine();
35 for (int i = 0; i < line.length(); i++) {
36 final int chamber = line.charAt(i) - '0';
37 if (chamber == 1) {
38 numLoaded++;
40 chambers.add(chamber);
41 total++;
45 final int numEmpty = total - numLoaded;
46 int numLoadedAfterEmpty = 0;
47 for (int i = 0; i < chambers.size(); i++) {
48 if (chambers.get(i) == 0 && chambers.get((i + 1) % chambers.size()) == 1) {
49 numLoadedAfterEmpty++;
53 final double probRotate = (double) numLoaded / total;
54 final double probShoot = (double) numLoadedAfterEmpty / numEmpty;
56 if (Math.abs(probRotate - probShoot) < 1e-6) {
57 out.println("EQUAL");
58 } else if (probRotate < probShoot) {
59 out.println("ROTATE");
60 } else {
61 out.println("SHOOT");