#include <cstdio> #include <cassert> #include <vector> #include <list> using namespace std; int t; enum Result{LOSE,DRAW,WIN}; Result aResults[100000]; int auPairCount[100000]; int main() { scanf("%d",&t); for(int i=0;i<t;++i) { int n = 0, m = 0; scanf("%d %d",&n,&m); for(int k=0;k<n;++k) { aResults[k] = LOSE; auPairCount[k] = 0; } for(int j=0;j<m;++j) { int a=0,b=0; char w=0; scanf("%d %c %d",&a,&w,&b); Result eResult = DRAW; if(w=='<') { eResult = LOSE; } else if (w=='>') { eResult = WIN; } else { assert(false); } if( aResults[b-1] > eResult || auPairCount[b-1]==0) { aResults[b-1] = eResult; } auPairCount[b-1]++; } for(int j=0;j<n;++j) { if(auPairCount[j]<n) { if( aResults[j] > DRAW ) { aResults[j] = DRAW; } } if( auPairCount[j] == 0 ) { aResults[j] = DRAW; } } Result eFinalResult = LOSE; for(int j=0; j<n; ++j) { if(aResults[j] > eFinalResult) { eFinalResult = aResults[j]; } } if(eFinalResult==WIN) { printf("WYGRANA\n"); } else if (eFinalResult==DRAW) { printf("REMIS\n"); } else if (eFinalResult==LOSE) { printf("PRZEGRANA\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 | #include <cstdio> #include <cassert> #include <vector> #include <list> using namespace std; int t; enum Result{LOSE,DRAW,WIN}; Result aResults[100000]; int auPairCount[100000]; int main() { scanf("%d",&t); for(int i=0;i<t;++i) { int n = 0, m = 0; scanf("%d %d",&n,&m); for(int k=0;k<n;++k) { aResults[k] = LOSE; auPairCount[k] = 0; } for(int j=0;j<m;++j) { int a=0,b=0; char w=0; scanf("%d %c %d",&a,&w,&b); Result eResult = DRAW; if(w=='<') { eResult = LOSE; } else if (w=='>') { eResult = WIN; } else { assert(false); } if( aResults[b-1] > eResult || auPairCount[b-1]==0) { aResults[b-1] = eResult; } auPairCount[b-1]++; } for(int j=0;j<n;++j) { if(auPairCount[j]<n) { if( aResults[j] > DRAW ) { aResults[j] = DRAW; } } if( auPairCount[j] == 0 ) { aResults[j] = DRAW; } } Result eFinalResult = LOSE; for(int j=0; j<n; ++j) { if(aResults[j] > eFinalResult) { eFinalResult = aResults[j]; } } if(eFinalResult==WIN) { printf("WYGRANA\n"); } else if (eFinalResult==DRAW) { printf("REMIS\n"); } else if (eFinalResult==LOSE) { printf("PRZEGRANA\n"); } } return 0; } |