import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class kar { public static final String REMIS = "REMIS"; public static final String PRZEGRANA = "PRZEGRANA"; public static final String WYGRANA = "WYGRANA"; public static void main(String[] args) { final Scanner in = new Scanner(System.in); final int tests = in.nextInt(); for (int i = 0; i < tests; i++) { final int decks = in.nextInt(); final int different = in.nextInt(); if (decks > different) { System.out.println(REMIS); skip(different, in); continue; } else { Set<Integer> wygTab = new HashSet<Integer>(); Set<Integer> przegTab = new HashSet<Integer>(); for (int j = 0; j < different; j++) { int a = in.nextInt(); String op = in.next(); int b = in.nextInt(); if (">".equals(op)) { wygTab.add(a); } else { przegTab.add(b); } } if (wygTab.size() - different >= 0) { System.out.println(WYGRANA); } else if (przegTab.size() - different >= 0) { System.out.println(PRZEGRANA); } else { System.out.println(REMIS); } } } System.exit(0); } private static void skip(final int different, final Scanner in) { for (int i = 0; i <= different; i++) in.nextLine(); } }
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 65 66 67 68 69 70 | import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class kar { public static final String REMIS = "REMIS"; public static final String PRZEGRANA = "PRZEGRANA"; public static final String WYGRANA = "WYGRANA"; public static void main(String[] args) { final Scanner in = new Scanner(System.in); final int tests = in.nextInt(); for (int i = 0; i < tests; i++) { final int decks = in.nextInt(); final int different = in.nextInt(); if (decks > different) { System.out.println(REMIS); skip(different, in); continue; } else { Set<Integer> wygTab = new HashSet<Integer>(); Set<Integer> przegTab = new HashSet<Integer>(); for (int j = 0; j < different; j++) { int a = in.nextInt(); String op = in.next(); int b = in.nextInt(); if (">".equals(op)) { wygTab.add(a); } else { przegTab.add(b); } } if (wygTab.size() - different >= 0) { System.out.println(WYGRANA); } else if (przegTab.size() - different >= 0) { System.out.println(PRZEGRANA); } else { System.out.println(REMIS); } } } System.exit(0); } private static void skip(final int different, final Scanner in) { for (int i = 0; i <= different; i++) in.nextLine(); } } |