#include <bits/stdc++.h>
using namespace std;
void test() {
int n, m;
scanf("%d %d", &n, &m);
array<vector<int>, 2> deg;
for(auto & v : deg) v.resize(n);
for(int i=0; i<m; i++) {
int a, b; char c;
scanf("%d %c %d", &a, &c, &b);
deg[c == '<'][b - 1] ++;
}
bool wyg = false;
for(int i=0; i<n; i++) if(deg[0][i] == n) wyg = true;
if(wyg) { puts("WYGRANA"); return; }
bool rem = false;
for(int i=0; i<n; i++) if(deg[1][i] == 0) rem = true;
if(rem) { puts("REMIS"); return; }
puts("PRZEGRANA");
}
int main() {
int t;
scanf("%d", &t);
for(int i=0; i<t; i++) test();
}
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 | #include <bits/stdc++.h> using namespace std; void test() { int n, m; scanf("%d %d", &n, &m); array<vector<int>, 2> deg; for(auto & v : deg) v.resize(n); for(int i=0; i<m; i++) { int a, b; char c; scanf("%d %c %d", &a, &c, &b); deg[c == '<'][b - 1] ++; } bool wyg = false; for(int i=0; i<n; i++) if(deg[0][i] == n) wyg = true; if(wyg) { puts("WYGRANA"); return; } bool rem = false; for(int i=0; i<n; i++) if(deg[1][i] == 0) rem = true; if(rem) { puts("REMIS"); return; } puts("PRZEGRANA"); } int main() { int t; scanf("%d", &t); for(int i=0; i<t; i++) test(); } |
English