// kar.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <list>
#include <math.h>
using namespace std;
int* newTable(int size)
{
int* table = new int[size];
for (int i = 0; i < size; i++)
{
table[i] = 0;
}
return table;
}
void zestaw()
{
int n, m;
cin >> n >> m;
int * countWygr = newTable(n+1);
int * arrayPrzegr = newTable(n+1);
int wyn = 0;
int countPrzegr = 0;
for (int j = 0; j < m; j++)
{
int a, b;
char rel;
cin >> a;
cin >> rel;
cin >> b;
if (rel == '>')
{
if (++(countWygr[b]) == n)
{
wyn = 1;
}
}
else
{
if (0 == (arrayPrzegr[b])++)
{
countPrzegr++;
}
}
}
if (wyn == 1)
{
cout << "WYGRANA" << endl;
}
else if (countPrzegr == n)
{
cout << "PRZEGRANA" << endl;
}
else
{
cout << "REMIS" << endl;
}
delete[] countWygr;
delete[] arrayPrzegr;
}
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
zestaw();
}
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 | // kar.cpp : Defines the entry point for the console application. // #include <iostream> #include <cstring> #include <cstdlib> #include <list> #include <math.h> using namespace std; int* newTable(int size) { int* table = new int[size]; for (int i = 0; i < size; i++) { table[i] = 0; } return table; } void zestaw() { int n, m; cin >> n >> m; int * countWygr = newTable(n+1); int * arrayPrzegr = newTable(n+1); int wyn = 0; int countPrzegr = 0; for (int j = 0; j < m; j++) { int a, b; char rel; cin >> a; cin >> rel; cin >> b; if (rel == '>') { if (++(countWygr[b]) == n) { wyn = 1; } } else { if (0 == (arrayPrzegr[b])++) { countPrzegr++; } } } if (wyn == 1) { cout << "WYGRANA" << endl; } else if (countPrzegr == n) { cout << "PRZEGRANA" << endl; } else { cout << "REMIS" << endl; } delete[] countWygr; delete[] arrayPrzegr; } int main() { int t; cin >> t; for (int i = 0; i < t; i++) { zestaw(); } return 0; } |
English