#include <cstdio> int main() { int t, n, m; scanf("%d", &t); for(int p=0; p<t; p++){ scanf("%d%d", &n, &m); if(m<n){ int a, b; char z[3]; printf("REMIS\n"); for(int o=0; o<m; o++){ scanf("%d%3c%d", &a, &z, &b); } } else { int* loseAgainst = new int[n+1]; int* winAgainst = new int[n+1]; for(int i=0; i<=n; i++){ loseAgainst[i]=0; winAgainst[i]=0; } for(int o=0; o<m; o++){ int a, b; char z[3]; scanf("%d%3c%d", &a, &z, &b); if(z[1]=='<'){ winAgainst[b]++; }else if(z[1]=='>'){ loseAgainst[b]++; } } int win = 0; int lose =0; for(int i=1; i<=n; i++) { if (loseAgainst[i] == n) { win++; } if (winAgainst[i]>0){ lose++; } } if(lose == n ){ printf("PRZEGRANA\n"); } else if(win>0){ printf("WYGRANA\n"); }else{ printf("REMIS\n"); } delete[] loseAgainst; delete[] winAgainst; } } 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 | #include <cstdio> int main() { int t, n, m; scanf("%d", &t); for(int p=0; p<t; p++){ scanf("%d%d", &n, &m); if(m<n){ int a, b; char z[3]; printf("REMIS\n"); for(int o=0; o<m; o++){ scanf("%d%3c%d", &a, &z, &b); } } else { int* loseAgainst = new int[n+1]; int* winAgainst = new int[n+1]; for(int i=0; i<=n; i++){ loseAgainst[i]=0; winAgainst[i]=0; } for(int o=0; o<m; o++){ int a, b; char z[3]; scanf("%d%3c%d", &a, &z, &b); if(z[1]=='<'){ winAgainst[b]++; }else if(z[1]=='>'){ loseAgainst[b]++; } } int win = 0; int lose =0; for(int i=1; i<=n; i++) { if (loseAgainst[i] == n) { win++; } if (winAgainst[i]>0){ lose++; } } if(lose == n ){ printf("PRZEGRANA\n"); } else if(win>0){ printf("WYGRANA\n"); }else{ printf("REMIS\n"); } delete[] loseAgainst; delete[] winAgainst; } } return 0; } |