#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100020;
int main(){
int t;
cin >> t;
for (int lt = 0; lt < t; lt++) {
int n, m;
int zIlomaPrzegrywa[MAX_N];
bool wygrana = false;
bool remis = false;
bool czyZKimsWygrywa[MAX_N];
cin >> n >> m;
for (int i = 0; i <= n + 5; i++) {
zIlomaPrzegrywa[i] = 0;
czyZKimsWygrywa[i] = false;
}
//zliczanie
for (int i = 0; i < m; i++) {
int a, b;
char w;
cin >> a >> w >> b;
if (w == '>')
zIlomaPrzegrywa[b]++;
else
czyZKimsWygrywa[b] = true;
}
//sprawdzanie
for (int i = 1; i <= n; i++) {
if (zIlomaPrzegrywa[i] >= n)
wygrana = true;
if (!czyZKimsWygrywa[i])
remis = true;
}
if (wygrana)
cout << "WYGRANA" << endl;
else if (remis)
cout << "REMIS" << endl;
else
cout << "PRZEGRANA" << 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 | #include <iostream> #include <algorithm> using namespace std; const int MAX_N = 100020; int main(){ int t; cin >> t; for (int lt = 0; lt < t; lt++) { int n, m; int zIlomaPrzegrywa[MAX_N]; bool wygrana = false; bool remis = false; bool czyZKimsWygrywa[MAX_N]; cin >> n >> m; for (int i = 0; i <= n + 5; i++) { zIlomaPrzegrywa[i] = 0; czyZKimsWygrywa[i] = false; } //zliczanie for (int i = 0; i < m; i++) { int a, b; char w; cin >> a >> w >> b; if (w == '>') zIlomaPrzegrywa[b]++; else czyZKimsWygrywa[b] = true; } //sprawdzanie for (int i = 1; i <= n; i++) { if (zIlomaPrzegrywa[i] >= n) wygrana = true; if (!czyZKimsWygrywa[i]) remis = true; } if (wygrana) cout << "WYGRANA" << endl; else if (remis) cout << "REMIS" << endl; else cout << "PRZEGRANA" << endl; } return 0; } |
English