Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

又一个贴代码的!

Posted by sEMpRMAjIA at 2006-08-22 21:25:39 on Problem 2492
In Reply To:AC了的程序,仅供参考 Posted by:A861223 at 2006-08-22 21:22:15
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator