| ||||||||||
| 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 | |||||||||
AC了的程序,仅供参考#define maxn 2001
#include<stdio.h>
#include<string.h>
int g[3]={0,2,1};
int num,fro,beh,n,q,m,x,y,p[2*maxn],f[maxn][maxn],use[maxn],color[maxn];
void task1()
{ int j1;
memset(f,0,sizeof(f));memset(use,0,sizeof(use));memset(color,0,sizeof(color));
scanf("%d %d",&n,&m);
for(j1=1;j1<=m;j1++)
{scanf("%d %d",&x,&y);
f[x][0]+=1;f[x][f[x][0]]=y;
f[y][0]+=1;f[y][f[y][0]]=x;
}
}
void main()
{int i1,j,z;
scanf("%d",&q);
for (i1=1;i1<=q;i1++)
{ task1();z=0;num=0;
do
{for (j=1;j<=n;j++) if (use[j]==0) break;
memset(p,0,sizeof(p));use[j]=1;color[j]=1;p[1]=j;fro=0;beh=1;num+=1;
do
{fro+=1;
for(j=1;j<=f[p[fro]][0];j++)
if (use[f[p[fro]][j]]==1&&color[f[p[fro]][j]]==color[p[fro]]) {z=1;break;}
else if (use[f[p[fro]][j]]==0)
{
beh+=1;p[beh]=f[p[fro]][j];
color[f[p[fro]][j]]=g[color[p[fro]]];
use[f[p[fro]][j]]=1;num+=1;
}
if (z==1) break;}
while (fro<=beh);
if (z==1) break; }
while (num<n);
printf("Scenario #%d:\n",i1);
if(z==1) printf("Suspicious bugs found!\n");
else printf("No suspicious bugs found!\n");
printf("\n");
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator