标签:else mission ini void wrong limit strong BMI sso
Time Limit: 10000MS | Memory Limit: 65536K | |
Total Submissions: 41952 | Accepted: 13619 |
Description
Input
Output
Sample Input
2 3 3 1 2 2 3 1 3 4 2 1 2 3 4
Sample Output
Scenario #1: Suspicious bugs found! Scenario #2: No suspicious bugs found!
感觉像套模板似的qwq。
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 const int maxn=2006; 5 int fa[maxn],val[maxn]; 6 7 void init() 8 { 9 for(int i=0;i<maxn;i++){ 10 fa[i]=i; 11 val[i]=0; 12 } 13 } 14 15 int find_fa(int x) 16 { 17 if(fa[x]==x) return x; 18 int tmp=fa[x]; 19 fa[x]=find_fa(tmp); 20 val[x]=val[x]^val[tmp]; 21 return fa[x]; 22 } 23 24 int main() 25 { 26 int T; 27 scanf("%d",&T); 28 for(int kkk=1;kkk<=T;kkk++){ 29 int n,m; 30 scanf("%d%d",&n,&m); 31 init(); 32 int ans=0; 33 for(int i=1;i<=m;i++){ 34 int x,y; 35 scanf("%d%d",&x,&y); 36 int opx,opy,tmp=1; 37 opx=find_fa(x); 38 opy=find_fa(y); 39 if(opx!=opy){ 40 fa[opy]=opx; 41 val[opy]=val[x]^val[y]^tmp; 42 } 43 if(opx==opy&&val[x]^val[y]!=tmp){ 44 ans=1; 45 } 46 } 47 printf("Scenario #%d:\n",kkk); 48 if(ans==1) printf("Suspicious bugs found!\n\n"); 49 else printf("No suspicious bugs found!\n\n"); 50 } 51 return 0; 52 }
标签:else mission ini void wrong limit strong BMI sso
原文地址:https://www.cnblogs.com/ZQUACM-875180305/p/9108737.html