#include <stdio.h>
int n,m;
int t;
int cnt[100100];
int cnt2[100100];
char * txt[] = { "PRZEGRANA", "REMIS", "WYGRANA" };
int main() {
int i;
scanf("%d",&t);
for (i = 0; i < t; i++) {
int j, res = 0;
memset(cnt, 0, sizeof(cnt));
memset(cnt2, 0, sizeof(cnt2));
scanf("%d%d",&n,&m);
for (j = 0; j < m; j++) {
int a,b,d;
scanf("%d %c%d",&a,&d,&b); a--; b--;
d = d=='>';
if (d && ++cnt[b] == n) res = 1;
if (!d) cnt2[b] = 1;
}
for (j = 0; j<n; j++) if (!cnt2[j]) break;
if (j == n) res = -1;
puts(txt[res+1]);
}
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 | #include <stdio.h> int n,m; int t; int cnt[100100]; int cnt2[100100]; char * txt[] = { "PRZEGRANA", "REMIS", "WYGRANA" }; int main() { int i; scanf("%d",&t); for (i = 0; i < t; i++) { int j, res = 0; memset(cnt, 0, sizeof(cnt)); memset(cnt2, 0, sizeof(cnt2)); scanf("%d%d",&n,&m); for (j = 0; j < m; j++) { int a,b,d; scanf("%d %c%d",&a,&d,&b); a--; b--; d = d=='>'; if (d && ++cnt[b] == n) res = 1; if (!d) cnt2[b] = 1; } for (j = 0; j<n; j++) if (!cnt2[j]) break; if (j == n) res = -1; puts(txt[res+1]); } return 0; } |
English