#include <iostream> #include <algorithm> #include <cstring> using namespace std; int main() { std::ios::sync_with_stdio(false); int tests; cin >> tests; for (int i = 0; i < tests; ++i) { int talie, pary; cin >> talie >> pary; unsigned long int tab_baj[talie+1], tab_bit[talie+1]; memset(tab_baj, 0, sizeof(tab_baj)); memset(tab_bit, 0, sizeof(tab_bit)); for (int j = 0; j < pary; ++j) { int number, number1; char znak_win; cin >> number >> znak_win >> number1; if (znak_win == '>') { tab_baj[number]++; } else { tab_bit[number1]++; } } sort(tab_baj, tab_baj + talie); sort(tab_bit, tab_bit + talie); for (int i = talie; i > 0; i--) { if (i == 0) { if (tab_baj[0] > tab_bit[0]) { cout << "WYGRANA" << endl; break; } else if (tab_baj[0] < tab_bit[0]) { cout << "PRZEGRANA" << endl; break; } else { cout << "REMIS" << endl; break; } } else if (tab_baj[i] == 0 && tab_bit[i] != 0) { cout << "PRZEGRANA" << endl; break; } else if (tab_baj[i] != 0 && tab_bit[i] == 0) { cout << "WYGRANA" << endl; break; } else if (tab_baj[i] == 0 && tab_bit[i] == 0) { cout << "REMIS" << endl; break; } else if (tab_baj[i] != 0 && tab_bit[i] != 0) { tab_baj[i] = 0; tab_bit[i] = 0; } } } 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 | #include <iostream> #include <algorithm> #include <cstring> using namespace std; int main() { std::ios::sync_with_stdio(false); int tests; cin >> tests; for (int i = 0; i < tests; ++i) { int talie, pary; cin >> talie >> pary; unsigned long int tab_baj[talie+1], tab_bit[talie+1]; memset(tab_baj, 0, sizeof(tab_baj)); memset(tab_bit, 0, sizeof(tab_bit)); for (int j = 0; j < pary; ++j) { int number, number1; char znak_win; cin >> number >> znak_win >> number1; if (znak_win == '>') { tab_baj[number]++; } else { tab_bit[number1]++; } } sort(tab_baj, tab_baj + talie); sort(tab_bit, tab_bit + talie); for (int i = talie; i > 0; i--) { if (i == 0) { if (tab_baj[0] > tab_bit[0]) { cout << "WYGRANA" << endl; break; } else if (tab_baj[0] < tab_bit[0]) { cout << "PRZEGRANA" << endl; break; } else { cout << "REMIS" << endl; break; } } else if (tab_baj[i] == 0 && tab_bit[i] != 0) { cout << "PRZEGRANA" << endl; break; } else if (tab_baj[i] != 0 && tab_bit[i] == 0) { cout << "WYGRANA" << endl; break; } else if (tab_baj[i] == 0 && tab_bit[i] == 0) { cout << "REMIS" << endl; break; } else if (tab_baj[i] != 0 && tab_bit[i] != 0) { tab_baj[i] = 0; tab_bit[i] = 0; } } } return 0; } |