hdu_5961_传递(bitset)
题目链接:hdu_5961_传递
题意:
中文,不解释
题解:
上bitset卡常,很优美的就过去了
1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=a;i<=b;i++) 3 using namespace std; 4 typedef long long ll; 5 6 bitset<2020>Q[2020],P[2020],*pp,now; 7 8 int t,n; 9 char G[2020][2020]; 10 11 int check(bitset<2020>*pp) 12 { 13 F(i,1,n)F(j,1,n) 14 { 15 if(pp[i][j]) 16 { 17 now=((~pp[i])&pp[j]); 18 if(now.any())return 1; 19 } 20 } 21 return 0; 22 } 23 24 int main() 25 { 26 scanf("%d",&t); 27 while(t--) 28 { 29 scanf("%d",&n); 30 F(i,1,n)Q[i].reset(),P[i].reset(); 31 F(i,1,n)scanf("%s",&G[i][1]); 32 F(i,1,n)F(j,1,n) 33 { 34 if(G[i][j]=='P')P[i][j]=1; 35 if(G[i][j]=='Q')Q[i][j]=1; 36 } 37 if(check(P))puts("N"); 38 else if(check(Q))puts("N"); 39 else puts("T"); 40 41 } 42 return 0; 43 }