#include <cstdio> #include <cmath> #include <vector> #include <set> #include <list> #include <cstring> #include <queue> #include <deque> #include <stack> #include <utility> #include <algorithm> #include <functional> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; #define DRAW printf("REMIS\n") #define WIN printf("WYGRANA\n") #define LOSE printf("PRZEGRANA\n") #define NL printf("\n") #define REP(__i,__n) for(int __i = 0; __i < (__n); ++__i) #define FOREACH(__it,__T) for (__typeof(__T.BEG) __it = __T.BEG; __it != __T.END; ++__it) #define FOR(__i,__beg,__end) for (int __i = __beg; __i <= (__end); ++__i) #define FORD(__i,__end,__beg) for (int __i = __end; __i >= __beg; --__i) #define DEB_STR(__T) FOREACH(______iterT,__T) printf("%d ",*______iterT); printf("\n"); #define IS_2POW(__n) (((__n^(__n-1))&__n) == __n) #define BEG begin() #define END end() #define PB push_back #define PF push_front #define PU push #define POB pop_back() #define POF pop_front() #define PO pop() #define MP make_pair #define F first #define S second const bool DEBUG = false; const int INF = 1000000010, MAX = 100010; int t,n,m,a,b,left[MAX], right[MAX]; char c[2]; void clean_up() { FOR(i,0,n) { left[i] = 0; right[i] = 0; } } bool check_right () { for (int i = 1; i <= n; ++i) if (right[i] == 0) return false; return true; } bool check_left () { for (int i = 1; i <= n; ++i) if (left[i] == 0) return false; return true; } int main () { scanf("%d",&t); while (t--) { scanf("%d%d",&n,&m); clean_up(); FOR(i,1,m) { scanf("%d%s%d",&a,c,&b); if (c[0] == '>') left[a]++; else right[b]++; } if (DEBUG) FOR(i,1,n) printf("%d: %d %d\n", i, left[i], right[i]); if (check_right()) LOSE; else if (check_left()) WIN; else DRAW; } 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #include <cstdio> #include <cmath> #include <vector> #include <set> #include <list> #include <cstring> #include <queue> #include <deque> #include <stack> #include <utility> #include <algorithm> #include <functional> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; #define DRAW printf("REMIS\n") #define WIN printf("WYGRANA\n") #define LOSE printf("PRZEGRANA\n") #define NL printf("\n") #define REP(__i,__n) for(int __i = 0; __i < (__n); ++__i) #define FOREACH(__it,__T) for (__typeof(__T.BEG) __it = __T.BEG; __it != __T.END; ++__it) #define FOR(__i,__beg,__end) for (int __i = __beg; __i <= (__end); ++__i) #define FORD(__i,__end,__beg) for (int __i = __end; __i >= __beg; --__i) #define DEB_STR(__T) FOREACH(______iterT,__T) printf("%d ",*______iterT); printf("\n"); #define IS_2POW(__n) (((__n^(__n-1))&__n) == __n) #define BEG begin() #define END end() #define PB push_back #define PF push_front #define PU push #define POB pop_back() #define POF pop_front() #define PO pop() #define MP make_pair #define F first #define S second const bool DEBUG = false; const int INF = 1000000010, MAX = 100010; int t,n,m,a,b,left[MAX], right[MAX]; char c[2]; void clean_up() { FOR(i,0,n) { left[i] = 0; right[i] = 0; } } bool check_right () { for (int i = 1; i <= n; ++i) if (right[i] == 0) return false; return true; } bool check_left () { for (int i = 1; i <= n; ++i) if (left[i] == 0) return false; return true; } int main () { scanf("%d",&t); while (t--) { scanf("%d%d",&n,&m); clean_up(); FOR(i,1,m) { scanf("%d%s%d",&a,c,&b); if (c[0] == '>') left[a]++; else right[b]++; } if (DEBUG) FOR(i,1,n) printf("%d: %d %d\n", i, left[i], right[i]); if (check_right()) LOSE; else if (check_left()) WIN; else DRAW; } return 0; } |