fork download
  1.  
  2. import java.io.*;
  3. import java.util.*;
  4.  
  5. public class FastTravelerGame {
  6.  
  7. static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  8. static StringTokenizer st = new StringTokenizer("");
  9.  
  10. public static String next() {
  11. try {
  12. while (!st.hasMoreTokens()) {
  13. String s = br.readLine();
  14. if (s == null)
  15. return null;
  16. st = new StringTokenizer(s);
  17. }
  18. return st.nextToken();
  19. } catch(Exception e) {
  20. return null;
  21. }
  22. }
  23. public static void main(String[] asda) throws Exception {
  24. int CASES = Integer.parseInt( next() );
  25. while (CASES-- > 0) {
  26. int N = Integer.parseInt( next() ); // number of players
  27. int M = Integer.parseInt( next() ); // number of tiles
  28. int D = Integer.parseInt( next() ); // number of dices thrown
  29. int [] move = new int [M];
  30. for (int k = 0; k < M; k++) move[k] = Integer.parseInt( next() );
  31.  
  32. Queue<Integer> queue = new LinkedList<Integer>(); // player queue
  33. for (int k = 0; k < N; k++) queue.add(k);
  34.  
  35. List<Integer> winners = new LinkedList<Integer>();
  36. int [] pos = new int [N]; // current player position
  37. while (D-- > 0) {
  38. int x = Integer.parseInt( next() );
  39. if (queue.isEmpty()) {
  40. continue;
  41. }
  42. int p = queue.poll();
  43. pos[p] += x;
  44. pos[p] += move[ pos[p] ];
  45.  
  46. if (pos[p] + 1 == M) {
  47. winners.add(p + 1);
  48. } else {
  49. queue.add(p);
  50. }
  51. }
  52. if ( winners.isEmpty() ) {
  53. out.println(-1);
  54. } else {
  55. out.print( winners.remove(0) );
  56. while (!winners.isEmpty()) {
  57. out.print(" " + winners.remove(0));
  58. }
  59. out.println();
  60. }
  61. }
  62. //
  63. out.flush();
  64. System.exit(0);
  65. }
  66.  
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class FastTravelerGame is public, should be declared in a file named FastTravelerGame.java
public class FastTravelerGame  {
       ^
1 error
stdout
Standard output is empty