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 jiabiao at 2005-08-30 11:32:38 on Problem 2524
#include<stdio.h>
void main()
{
   long m,n,a[50000],i,b[50000][2],j,count,sum,k=1;
   while(1)
   {
      for(i=0;i<n;i++)
      a[i]=0;
      count=1;sum=0;
      scanf("%ld %ld",&n,&m);
      if(m==0&&n==0)
      break;
      for(i=0;i<m;i++)
      {
        scanf("%ld %ld",&b[i][0],&b[i][1]);
        for(j=0;j<i;j++)
        {
          if(b[i][0]!=b[j][0]&&b[i][0]!=b[j][1]&&b[i][1]!=b[j][0]&&b[i][1]!=b[j][1])
          {count++;b[j][0]=b[i][0];b[j][1]=b[i][1];}
        }
        a[b[i][0]-1]=1;a[b[i][1]-1]=1;
      }
      for(i=0;i<n;i++)
        if(a[i]==0)
        sum++;
      printf("Case %ld: %ld\n",k,sum+count);
      k++;
   }
}

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