#include <iostream>
#include <cstring>
#include <algorithm>
const std::string remis = "REMIS";
const std::string wygrana = "WYGRANA";
const std::string przegrana = "PRZEGRANA";
int W[100010];
char x[100010];
int kto()
{
int n, m, a, b;
char w;
std::cin >> n >> m;
if(m < n)
{
for(int j=0; j<m; j++)
std::cin >> a >> w >> b;
return 0;
}
else
{
std::fill_n(W, n+1, 0);
std::fill_n(x, n+1, 0);
for(int j=0; j<m; j++)
{
std::cin >> a >> w >> b;
if(w == '>')
{
W[b] ++;
}
else
{
x[b] |= 1;
}
}
for(int j=1; j<=n; j++)
{
if(W[j] == n)
return 1;
}
for(int j=1; j<=n; j++)
{
if(x[j] == 0)
return 0;
}
return -1;
}
}
int main()
{
int t;
std::cin >> t;
for(int i=0; i<t; i++)
{
switch(kto())
{
case 1:
std::cout << wygrana << std::endl;
break;
case 0:
std::cout << remis << std::endl;
break;
case -1:
std::cout << przegrana << std::endl;
}
}
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 | #include <iostream> #include <cstring> #include <algorithm> const std::string remis = "REMIS"; const std::string wygrana = "WYGRANA"; const std::string przegrana = "PRZEGRANA"; int W[100010]; char x[100010]; int kto() { int n, m, a, b; char w; std::cin >> n >> m; if(m < n) { for(int j=0; j<m; j++) std::cin >> a >> w >> b; return 0; } else { std::fill_n(W, n+1, 0); std::fill_n(x, n+1, 0); for(int j=0; j<m; j++) { std::cin >> a >> w >> b; if(w == '>') { W[b] ++; } else { x[b] |= 1; } } for(int j=1; j<=n; j++) { if(W[j] == n) return 1; } for(int j=1; j<=n; j++) { if(x[j] == 0) return 0; } return -1; } } int main() { int t; std::cin >> t; for(int i=0; i<t; i++) { switch(kto()) { case 1: std::cout << wygrana << std::endl; break; case 0: std::cout << remis << std::endl; break; case -1: std::cout << przegrana << std::endl; } } return 0; } |
English