//no comment needed #include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <string.h> #include <strings.h> #include <math.h> #include <time.h> #include <map> #include <climits> using namespace std; //Two of the most frequently used typical of long names, make life easier typedef vector<int> VI; typedef long long LL; /* HEADERS */ /* Loops */ // FOR - loop increasing 'x' from 'b' to 'e' inclusive #define FOR(x, b, e) for(int x = b; x <= (e); ++x) // FORD - loop decreasing 'x' from 'b' to 'e' inclusive #define FORD(x, b, e) for(int x = b; x >= (e); --x) // REP - loop increasing 'x' from '0' to 'n'. Used to search and build DS #define REP(x, n) for(int x = 0; x < (n); ++x) // Clone long type of 'n' #define VAR(v, n) __typeof(n) v = (n) // ALL(c) represents the pair of iterators, indicating begin-end elements in the STL DS #define ALL(c) (c).begin(), (c).end() //Macro to get size of STL DS, used to avoid compilation warrning with int and uint comp #define SIZE(x) ((int)(x).size()) // Very profitable macro aimed to iterate through all elements of STL DS #define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i) /* Shortcuts for vectors most common use cases*/ #define PB push_back #define POP pop_back #define ST first #define ND second #define RM( v, x ) v.erase(v.begin() + x) #define PF( v, x ) v.insert(v.begin(), x); #define FIND(v, x) find(v.begin(), v.end(), x) #define Vit std::vector<int>::iterator /* some other usefull methods */ #define INF INT_MAX/2-256 #define _il inline #define _ili inline int #define _ilv inline void #define IN "test.in" #define OUT "test.out" #define ERR "sample.err" _ili sol(int, int, int ); //debug print void print_v(VI v){ fprintf(stderr, "vec:: "); FOREACH(it, v) fprintf(stderr, "%d, ", *it); fprintf(stderr, "\n"); } #define PRZEGRANA -1 #define REMIS 0 #define WYGRANA 1 int main(){ //sample // freopen(IN, "r", stdin); // freopen(OUT, "w", stdout); // freopen(ERR, "w", stderr); int TT; cin >> TT; REP(tt, TT){ int n, m; cin >> n; cin >> m; int s = sol(tt+1, n, m); //run sol if(s == PRZEGRANA) printf("PRZEGRANA\n"); if(s == REMIS) printf("REMIS\n"); if(s == WYGRANA) printf("WYGRANA\n"); } return 0; } struct C { int i; VI v; static bool comp( const C& c1, const C& c2 ) { return c1.v.size() < c2.v.size(); } }; _ili sol(int tc, int N, int M) { VI bajt(N); vector<C> BAJT(N); VI bit(N); vector<C> BIT(N); for(int x=1; x <=N; x++){ BAJT[x-1].i=x; BIT[x-1].i=x;} //do work int a, b; char c; REP(m, M){ cin >> a; cin >> c; cin >> b; if(c == '>'){ bajt[a-1]++; BAJT[a-1].v.PB(b); } else{ bit[b-1]++; BIT[b-1].v.PB(a); } } int sbajt=0, ubajt=0; int sbit=0, ubit=0; FOREACH(i,bajt) if(*i) { sbajt+=*i; ubajt++; } FOREACH(i,bit) if(*i) { sbit+=*i; ubit++;} if(ubit > N) return PRZEGRANA; if(ubajt > N) return WYGRANA; if(ubajt < N && ubit < N) return REMIS; std::sort( BAJT.begin(), BAJT.end(), C::comp ); std::sort( BIT.begin(), BIT.end(), C::comp ); //Najprostrzy model: int bbjt = BAJT[0].i; int bbit = BIT[0].i; std::vector<int>::iterator it; if (!BAJT[0].v.empty()){ // int w = 0; // for(int i=0; i<N; i++){ // if(!BIT[i].v.empty) // break; // } // if(w>0) return WYGRANA; } if (!BIT[0].v.empty()) return PRZEGRANA; return REMIS; }
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | //no comment needed #include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <string.h> #include <strings.h> #include <math.h> #include <time.h> #include <map> #include <climits> using namespace std; //Two of the most frequently used typical of long names, make life easier typedef vector<int> VI; typedef long long LL; /* HEADERS */ /* Loops */ // FOR - loop increasing 'x' from 'b' to 'e' inclusive #define FOR(x, b, e) for(int x = b; x <= (e); ++x) // FORD - loop decreasing 'x' from 'b' to 'e' inclusive #define FORD(x, b, e) for(int x = b; x >= (e); --x) // REP - loop increasing 'x' from '0' to 'n'. Used to search and build DS #define REP(x, n) for(int x = 0; x < (n); ++x) // Clone long type of 'n' #define VAR(v, n) __typeof(n) v = (n) // ALL(c) represents the pair of iterators, indicating begin-end elements in the STL DS #define ALL(c) (c).begin(), (c).end() //Macro to get size of STL DS, used to avoid compilation warrning with int and uint comp #define SIZE(x) ((int)(x).size()) // Very profitable macro aimed to iterate through all elements of STL DS #define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i) /* Shortcuts for vectors most common use cases*/ #define PB push_back #define POP pop_back #define ST first #define ND second #define RM( v, x ) v.erase(v.begin() + x) #define PF( v, x ) v.insert(v.begin(), x); #define FIND(v, x) find(v.begin(), v.end(), x) #define Vit std::vector<int>::iterator /* some other usefull methods */ #define INF INT_MAX/2-256 #define _il inline #define _ili inline int #define _ilv inline void #define IN "test.in" #define OUT "test.out" #define ERR "sample.err" _ili sol(int, int, int ); //debug print void print_v(VI v){ fprintf(stderr, "vec:: "); FOREACH(it, v) fprintf(stderr, "%d, ", *it); fprintf(stderr, "\n"); } #define PRZEGRANA -1 #define REMIS 0 #define WYGRANA 1 int main(){ //sample // freopen(IN, "r", stdin); // freopen(OUT, "w", stdout); // freopen(ERR, "w", stderr); int TT; cin >> TT; REP(tt, TT){ int n, m; cin >> n; cin >> m; int s = sol(tt+1, n, m); //run sol if(s == PRZEGRANA) printf("PRZEGRANA\n"); if(s == REMIS) printf("REMIS\n"); if(s == WYGRANA) printf("WYGRANA\n"); } return 0; } struct C { int i; VI v; static bool comp( const C& c1, const C& c2 ) { return c1.v.size() < c2.v.size(); } }; _ili sol(int tc, int N, int M) { VI bajt(N); vector<C> BAJT(N); VI bit(N); vector<C> BIT(N); for(int x=1; x <=N; x++){ BAJT[x-1].i=x; BIT[x-1].i=x;} //do work int a, b; char c; REP(m, M){ cin >> a; cin >> c; cin >> b; if(c == '>'){ bajt[a-1]++; BAJT[a-1].v.PB(b); } else{ bit[b-1]++; BIT[b-1].v.PB(a); } } int sbajt=0, ubajt=0; int sbit=0, ubit=0; FOREACH(i,bajt) if(*i) { sbajt+=*i; ubajt++; } FOREACH(i,bit) if(*i) { sbit+=*i; ubit++;} if(ubit > N) return PRZEGRANA; if(ubajt > N) return WYGRANA; if(ubajt < N && ubit < N) return REMIS; std::sort( BAJT.begin(), BAJT.end(), C::comp ); std::sort( BIT.begin(), BIT.end(), C::comp ); //Najprostrzy model: int bbjt = BAJT[0].i; int bbit = BIT[0].i; std::vector<int>::iterator it; if (!BAJT[0].v.empty()){ // int w = 0; // for(int i=0; i<N; i++){ // if(!BIT[i].v.empty) // break; // } // if(w>0) return WYGRANA; } if (!BIT[0].v.empty()) return PRZEGRANA; return REMIS; } |