#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define ppb pop_back #define eb emplace_back #define e1 first #define e2 second #define For(a, b, i) for(int i=a;i<b; ++i) #define Dfor(a, b, i) for(int i=a;i>=b; --i) #define ll long long int #define ull unsigned long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pp pair<pii, pii> const int mod=1e9+7; const int inf=1e9+9; const int mod69=1e9+696969; #define maxn 200010 bool odw1[maxn], odw2[maxn]; void clear() { For(0, maxn, i) { odw1[i]=false; odw2[i]=false; } } int main() { int q; scanf("%d", &q); for(int f=0;f<q;f++) { int n,m; int a1=0,b1=0; scanf("%d%d", &n, &m); for(int i=0;i<m;i++) { int a,b; char x,y; scanf("%d", &a); scanf("%c", &y); scanf("%c", &x); scanf("%c", &y); scanf("%d", &b); if(x=='>' && odw1[a]==false) a1++,odw1[a]=true; else if(x=='<' && odw2[b]==false) b1++, odw2[b]=true; } if((a1<n && b1<n) || (n==0)) puts("REMIS"); else if(a1==n && b1<n) puts("WYGRANA"); else puts("PRZEGRANA"); clear(); } }
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 | #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define ppb pop_back #define eb emplace_back #define e1 first #define e2 second #define For(a, b, i) for(int i=a;i<b; ++i) #define Dfor(a, b, i) for(int i=a;i>=b; --i) #define ll long long int #define ull unsigned long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pp pair<pii, pii> const int mod=1e9+7; const int inf=1e9+9; const int mod69=1e9+696969; #define maxn 200010 bool odw1[maxn], odw2[maxn]; void clear() { For(0, maxn, i) { odw1[i]=false; odw2[i]=false; } } int main() { int q; scanf("%d", &q); for(int f=0;f<q;f++) { int n,m; int a1=0,b1=0; scanf("%d%d", &n, &m); for(int i=0;i<m;i++) { int a,b; char x,y; scanf("%d", &a); scanf("%c", &y); scanf("%c", &x); scanf("%c", &y); scanf("%d", &b); if(x=='>' && odw1[a]==false) a1++,odw1[a]=true; else if(x=='<' && odw2[b]==false) b1++, odw2[b]=true; } if((a1<n && b1<n) || (n==0)) puts("REMIS"); else if(a1==n && b1<n) puts("WYGRANA"); else puts("PRZEGRANA"); clear(); } } |