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 happynp at 2007-06-12 10:23:26 on Problem 1548
#include<stdio.h>
#include<memory.h>
#define  N  26
typedef struct point
{
	int x,y;
}point;
int main()
{ 
  int  i,j,k,gCount,ans;
  point  a[N*N],buf[N];
  int  X,Y;
  bool isEnd;
  while(1)
  {
	 i = 0;  
	 gCount = 0;
	 isEnd  = 0;
	 ans    = 1;
	 memset(a,0,sizeof(a));
	 memset(buf,0,sizeof(buf));
	 while(EOF!=scanf("%d%d",&a[i].x,&a[i].y))
	 {
       if(a[i].x==-1&&a[i].y==-1)
	   {
		   isEnd = 1;
	       break;
	   }
	   if(a[i].x==0&&a[i].y==0)
	      break;  
	   i++;
	 }
	 if(isEnd)
	    break;	 
   gCount = i;
   i = 1;
   j = 0;
   k = 1;
   X = a[0].x;
   Y = a[0].y; 
   while(k<gCount)
   {
	if(i<gCount)
	{   
      if(a[i].x==X){
		  if(a[i].y>=Y){
			  X = a[i].x;
			  Y = a[i].y;
			  i++;
			  k++;
		  }
	  }
	  else{
		  if(a[i].y<Y){
            buf[j++] = a[i++];
		  }
		  else{
		      X = a[i].x;
			  Y = a[i].y;
			  i++;
			  k++;
		  }
	  }
	}
	else{
	    memcpy(a,buf,sizeof(point)*gCount);
		memset(buf,0,sizeof(buf));
	    i = 0;
		j = 0;
		ans++;
        X = a[0].x;
		Y = a[0].y;
	}
   }
   printf("%d\n",ans);
  } 	 
  return 0;
}

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