import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class kar { public static void main(String[] args) throws IOException { InputScanner is = new InputScanner(); int t = is.nextInt(); String WYGRANA = "WYGRANA"; String REMIS = "REMIS"; String PRZEGRANA = "PRZEGRANA"; for (int i = 0; i < t; i++) { int n = is.nextInt(); int m = is.nextInt(); int[] gameResult = new int[n]; int a, b; String sign; for (int j = 0; j < m; j++) { a = is.nextInt() - 1; sign = is.next(); b = is.nextInt() - 1; if (sign.equals(">")) gameResult[a] = 1; else gameResult[a] = -1; } int minVaue = 2; for (int j = 0; j < n; j++) { if (gameResult[j] < minVaue) minVaue = gameResult[j]; } if (minVaue == -1) System.out.println(PRZEGRANA); else if (minVaue == 0) System.out.println(REMIS); else System.out.println(WYGRANA); } } static class InputScanner { BufferedReader br; StringTokenizer st; public InputScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } public String next() throws IOException { if (st == null || !st.hasMoreTokens()) { String line = br.readLine(); st = new StringTokenizer(line); } return st.nextToken(); } public int nextInt() throws IOException { String next = next(); return Integer.parseInt(next); } public long nextLong() throws IOException { String next = next(); return Long.parseLong(next); } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class kar { public static void main(String[] args) throws IOException { InputScanner is = new InputScanner(); int t = is.nextInt(); String WYGRANA = "WYGRANA"; String REMIS = "REMIS"; String PRZEGRANA = "PRZEGRANA"; for (int i = 0; i < t; i++) { int n = is.nextInt(); int m = is.nextInt(); int[] gameResult = new int[n]; int a, b; String sign; for (int j = 0; j < m; j++) { a = is.nextInt() - 1; sign = is.next(); b = is.nextInt() - 1; if (sign.equals(">")) gameResult[a] = 1; else gameResult[a] = -1; } int minVaue = 2; for (int j = 0; j < n; j++) { if (gameResult[j] < minVaue) minVaue = gameResult[j]; } if (minVaue == -1) System.out.println(PRZEGRANA); else if (minVaue == 0) System.out.println(REMIS); else System.out.println(WYGRANA); } } static class InputScanner { BufferedReader br; StringTokenizer st; public InputScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } public String next() throws IOException { if (st == null || !st.hasMoreTokens()) { String line = br.readLine(); st = new StringTokenizer(line); } return st.nextToken(); } public int nextInt() throws IOException { String next = next(); return Integer.parseInt(next); } public long nextLong() throws IOException { String next = next(); return Long.parseLong(next); } } } |