题解:P11604 [PA 2016] 卡牌 / Gra w karty
[PA 2016] 卡牌 / Gra w karty
大受震撼,感觉不止黄吧。
分别考虑
若
对于
而对于
#include<bits/stdc++.h>
#define ll long long
#define pn putchar('\n')
#define mset(a,x) memset(a,x,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define fls() fflush(stdout)
using namespace std;
int re()
{
int x=0;
bool t=1;
char ch=getchar();
while(ch>'9'||ch<'0')
t=ch=='-'?0:t,ch=getchar();
while(ch>='0'&&ch<='9')
x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return t?x:-x;
}
const int maxn=2e5+5;
int n,m;
int cd[maxn],rd[maxn];
void solve()
{
n=re(),m=re();
mset(cd,0);
mset(rd,0);
while(m--)
{
int u=re();
char ch=getchar();
int v=re();
if(ch=='>')
rd[v]++;
else
cd[v]++;
}
bool ans=1;
for(int i=1;i<=n;i++)
{
if(rd[i]==n)
{
puts("WYGRANA");
return;
}
if(!cd[i])
ans=0;
}
puts(ans?"PRZEGRANA":"REMIS");
}
signed main()
{
int T=re();
while(T--)
solve();
return 0;
}