| ||||||||||
| 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 | |||||||||
想不通,怎么超时的,哪位帮看看#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator