#include <bits/stdc++.h>
using namespace std;
int t, n, a, b, m, ile;
char c;
int cnt[100007][2];//we wy
void zer()
{
for(int i = 0; i <= n; i++)
cnt[i][0] = cnt[i][1] = 0;
}
int main()
{
scanf("%d", &t);
while(t--)
{
bool rem = 0, wyg = 0;
scanf("%d %d", &n, &m);
ile = n;
for(int i = 0; i < m; i++)
{
scanf("%d %c %d", &a, &c, &b);
if(c =='<') cnt[b][1] ++;
else cnt[b][0] ++;
}
for(int i = 1; i <= n; i++)
{
if(cnt[i][1] == 0) rem = 1;
if(cnt[i][0] == n) wyg = 1;
}
if(rem && wyg) puts("WYGRANA");
else if(rem) puts("REMIS");
else puts("PRZEGRANA");
zer();
}
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 | #include <bits/stdc++.h> using namespace std; int t, n, a, b, m, ile; char c; int cnt[100007][2];//we wy void zer() { for(int i = 0; i <= n; i++) cnt[i][0] = cnt[i][1] = 0; } int main() { scanf("%d", &t); while(t--) { bool rem = 0, wyg = 0; scanf("%d %d", &n, &m); ile = n; for(int i = 0; i < m; i++) { scanf("%d %c %d", &a, &c, &b); if(c =='<') cnt[b][1] ++; else cnt[b][0] ++; } for(int i = 1; i <= n; i++) { if(cnt[i][1] == 0) rem = 1; if(cnt[i][0] == n) wyg = 1; } if(rem && wyg) puts("WYGRANA"); else if(rem) puts("REMIS"); else puts("PRZEGRANA"); zer(); } return 0; } |
English