#include <iostream> #include <stdio.h> #include <map> using namespace std; int main() { int T; scanf("%d", &T); for (int t=0; t<T; t++) { int N; int M; scanf("%d %d", &N, &M); int lWin[N]; int rWin[N]; int llWin[N]; int rrWin[N]; for (int n=0;n<N;n++) { lWin[n]=0; rWin[n]=0; llWin[n]=0; rrWin[n]=0; } for (int m=0;m<M;m++) { int a; int b; char w; scanf("%d %c %d", &a, &w, &b); if (w == '>') { lWin[a-1]++; llWin[b-1]++; } else { rWin[b-1]++; rrWin[a-1]++; } } int lowL = 2000000; int lowLIndex = 0; int lowR = 2000000; int lowRIndex = 0; for (int n=0;n<N;n++) { if (lWin[n] < lowL) { lowLIndex = n; lowL = lWin[n]; } if (rWin[n] < lowR) { lowRIndex = n; lowR = rWin[n]; } } bool allL=true; for (int n=0;n<N;n++) { if (llWin[n] != 1) allL = false; } if ((allL) && N != 1) { printf("REMIS\n"); } else if (lWin[lowLIndex] >= 1) { printf("WYGRANA\n"); } else if (lWin[lowLIndex] == 0 && rWin[lowRIndex] == 0) { printf("REMIS\n"); } else { printf("PRZEGRANA\n"); } } printf("\n"); return 0; }
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 86 87 | #include <iostream> #include <stdio.h> #include <map> using namespace std; int main() { int T; scanf("%d", &T); for (int t=0; t<T; t++) { int N; int M; scanf("%d %d", &N, &M); int lWin[N]; int rWin[N]; int llWin[N]; int rrWin[N]; for (int n=0;n<N;n++) { lWin[n]=0; rWin[n]=0; llWin[n]=0; rrWin[n]=0; } for (int m=0;m<M;m++) { int a; int b; char w; scanf("%d %c %d", &a, &w, &b); if (w == '>') { lWin[a-1]++; llWin[b-1]++; } else { rWin[b-1]++; rrWin[a-1]++; } } int lowL = 2000000; int lowLIndex = 0; int lowR = 2000000; int lowRIndex = 0; for (int n=0;n<N;n++) { if (lWin[n] < lowL) { lowLIndex = n; lowL = lWin[n]; } if (rWin[n] < lowR) { lowRIndex = n; lowR = rWin[n]; } } bool allL=true; for (int n=0;n<N;n++) { if (llWin[n] != 1) allL = false; } if ((allL) && N != 1) { printf("REMIS\n"); } else if (lWin[lowLIndex] >= 1) { printf("WYGRANA\n"); } else if (lWin[lowLIndex] == 0 && rWin[lowRIndex] == 0) { printf("REMIS\n"); } else { printf("PRZEGRANA\n"); } } printf("\n"); return 0; } |