| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不是二分图的判断吗?怎么我这样做错了啊?哪位大牛帮忙看下~~#include<stdio.h>
#include<string.h>
int color[3000];
int chek(long a,long b)
{
int x,y;
x=color[a];
y=color[b];
if(x==0&&y==0)
{
color[a]=1;
color[b]=-1;
}
else if(x==0&&y!=0) color[a]=color[b]*(-1);
else if(x!=0&&y==0) color[b]=color[a]*(-1);
else if(x!=0&&y!=0&&x==y) return 1;
return 0;
}
main()
{
long n,m,i,j,a,b,ok,case1=1,test;
scanf("%ld",&test);
while(test--)
{
scanf("%ld%ld",&n,&m);
ok=0;
memset(color,0,sizeof(color));
for(i=0;i<m;i++)
{
scanf("%ld%ld",&a,&b);
if(ok) continue;
else ok=chek(a,b);
}
printf("Scenario #%ld:\n",case1++);
if(ok) printf("Suspicious bugs found!\n");
else printf("No suspicious bugs found!\n");
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator