题目链接:hdu_5961_传递
题意:
中文,不解释
题解:
上bitset卡常,很优美的就过去了
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll; bitset<>Q[],P[],*pp,now; int t,n;
char G[][]; int check(bitset<>*pp)
{
F(i,,n)F(j,,n)
{
if(pp[i][j])
{
now=((~pp[i])&pp[j]);
if(now.any())return ;
}
}
return ;
} int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
F(i,,n)Q[i].reset(),P[i].reset();
F(i,,n)scanf("%s",&G[i][]);
F(i,,n)F(j,,n)
{
if(G[i][j]=='P')P[i][j]=;
if(G[i][j]=='Q')Q[i][j]=;
}
if(check(P))puts("N");
else if(check(Q))puts("N");
else puts("T"); }
return ;
}