标签:
#include<stdio.h>
#include<string.h>
int bug[2010],num[2010];
int find(int x){
int r=x;
while(r!=bug[r])r=bug[r];
bug[x]=r;
return r;
}
void initial(){
memset(bug,0,sizeof(bug));
for(int i=1;i<=2000;i++)num[i]=1;
}
int merge(int x,int y){
int f1,f2;
f1=find(x);f2=find(y);
if(f1!=f2)bug[f2]=f1,num[f1]+=num[f2];
else return num[f1];
return 0;
}
int main(){
int T,N,M,a,b,flot,tot=0;
scanf("%d",&T);
while(T--){flot=1;tot++;initial();
scanf("%d%d",&N,&M);
while(M--){
scanf("%d%d",&a,&b);
if(!bug[a])bug[a]=a;if(!bug[b])bug[b]=b;
if(merge(a,b)&1)flot=0;
}
if(flot)printf("Scenario #%d:\nNo suspicious bugs found!\n",tot);
else printf("Scenario #%d:\nSuspicious bugs found!\n",tot);
puts("");
}
return 0;
}
//错的;;;
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4687555.html