标签:amp res numbers ace about tin mos each pos
ps:本来是想找个二分图判断的题来写,结果百度到这鬼题
#include<cstdio>
using namespace std;
#define max_n 2020*2
int par[max_n];
void init(int n)
{
for(int i=1;i<=n;i++)
{
par[i]=i;
}
}
int find(int x)
{
if(par[x]==x) return x;
else
{
return par[x]=find(par[x]);
}
}
bool same(int x,int y)
{
return find(x)==find(y);
}
void unit(int x,int y)
{
int fx=find(x);
int fy=find(y);
if(fx==fy) return ;
par[fx]=fy;
}
int main()
{
int t;
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
int flag=0;
int n,m;
scanf("%d%d",&n,&m);
init(n*2);
for(int j=0;j<m;j++)
{
int x,y;
scanf("%d%d",&x,&y);
if(same(x,y)||same(x+n,y+n))
{
printf("Scenario #%d:\nSuspicious bugs found!\n\n",i);
flag=1;
break;
}
else
{
unit(x,y+n);
unit(x+n,y);
}
}
if(flag==0)
{
printf("Scenario #%d:\nNo suspicious bugs found!\n\n",i);
}
}
return 0;
}
标签:amp res numbers ace about tin mos each pos
原文地址:http://www.cnblogs.com/onlyli/p/6763418.html