import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created by Lukasz.Dobrzynski on 16/11/22. */ public class kar { private int testNo; private int deckNo; private int noDrawNo; private int outcome; private int[][] deckOutcomes; private Set<Integer> winningDecksA = new HashSet<>(); private Set<Integer> winningDecksB = new HashSet<>(); private Scanner scanner = new Scanner(System.in); public static void main(String[] args) { kar app = new kar(); app.readTestNo(); for (int i = 0; i < app.testNo; i++) { app.clean(); app.readInput(); app.process(); app.writeOutput(); } } private void clean() { winningDecksA.clear(); winningDecksB.clear(); } private void writeOutput() { switch (outcome) { case -1: System.out.println("PRZEGRANA"); break; case 0: System.out.println("REMIS"); break; case 1: System.out.println("WYGRANA"); break; } } private void process() { if (winningDecksA.size() < deckNo && winningDecksB.size() < deckNo) { outcome = 0; return; } outcome = Integer.signum(winningDecksA.size() - winningDecksB.size()); } private void readTestNo() { testNo = scanner.nextInt(); } private void readInput() { deckNo = scanner.nextInt(); noDrawNo = scanner.nextInt(); for (int i = 0; i < noDrawNo; i++) { int deckA = scanner.nextInt(); boolean aWins = scanner.next("[<>]").equals(">"); int deckB = scanner.nextInt(); if (aWins) { winningDecksA.add(deckA); } else { winningDecksB.add(deckB); } } } }
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created by Lukasz.Dobrzynski on 16/11/22. */ public class kar { private int testNo; private int deckNo; private int noDrawNo; private int outcome; private int[][] deckOutcomes; private Set<Integer> winningDecksA = new HashSet<>(); private Set<Integer> winningDecksB = new HashSet<>(); private Scanner scanner = new Scanner(System.in); public static void main(String[] args) { kar app = new kar(); app.readTestNo(); for (int i = 0; i < app.testNo; i++) { app.clean(); app.readInput(); app.process(); app.writeOutput(); } } private void clean() { winningDecksA.clear(); winningDecksB.clear(); } private void writeOutput() { switch (outcome) { case -1: System.out.println("PRZEGRANA"); break; case 0: System.out.println("REMIS"); break; case 1: System.out.println("WYGRANA"); break; } } private void process() { if (winningDecksA.size() < deckNo && winningDecksB.size() < deckNo) { outcome = 0; return; } outcome = Integer.signum(winningDecksA.size() - winningDecksB.size()); } private void readTestNo() { testNo = scanner.nextInt(); } private void readInput() { deckNo = scanner.nextInt(); noDrawNo = scanner.nextInt(); for (int i = 0; i < noDrawNo; i++) { int deckA = scanner.nextInt(); boolean aWins = scanner.next("[<>]").equals(">"); int deckB = scanner.nextInt(); if (aWins) { winningDecksA.add(deckA); } else { winningDecksB.add(deckB); } } } } |