Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1.  
  2. import java.io.FileReader;
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.Comparator;
  6. import java.util.Scanner;
  7.  
  8. public class Solution {
  9.  
  10.     public static void main(String[] args) {
  11.         try {
  12.             String cad;
  13.             Scanner s = new Scanner(System.in);
  14.  
  15.             String sCurrentLine;
  16.             int T = 0;
  17.             int i;
  18.             int j;
  19.             int np;
  20.             boolean alice;
  21.             String a = "Alice";
  22.             String b = "Bob";
  23.             ArrayList<Integer> ps = new ArrayList<>();
  24.             while (s.hasNext()) {
  25.                 sCurrentLine = s.nextLine();
  26.                 T = Integer.parseInt(sCurrentLine);
  27.                 int G = 0;
  28.                 for (i = T - 1; i >= 0; --i) {
  29.                     sCurrentLine = s.nextLine();
  30.                     G = Integer.parseInt(sCurrentLine);
  31.                     np = 0;
  32.                     ps.clear();
  33.                     for (j = 0; j < G; j++) {
  34.                         sCurrentLine = s.nextLine();
  35.                         np = Integer.parseInt(sCurrentLine);
  36.                         sCurrentLine = s.nextLine();
  37.                         String[] p = sCurrentLine.split(" ");
  38.                         for (String c : p) {
  39.                             ps.add(Integer.valueOf(c));
  40.                         }
  41.                     }
  42.                     ////TODO////
  43.  
  44.                     alice = false;
  45.                     Collections.reverse(ps);
  46.                     while (!(ps.get(0) == 1)) {
  47.                         ps.add(1);
  48.                         ps.add(1);
  49.                         ps.add(ps.get(0) - 2);
  50.                         ps.remove(0);
  51.                         Collections.reverse(ps);
  52.                         alice = !alice;
  53.                     }
  54.                     System.out.println(alice ? a : b);
  55.  
  56.                 }
  57.             }
  58.         } catch (Exception e) {
  59.         } finally {
  60.         }
  61.  
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement