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 win163 at 2007-09-01 10:09:42 on Problem 2492
#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:
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