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

## 诡异的代码！！

Posted by mingruoyuan at 2009-06-26 09:46:09 on Problem 3626
```#include<stdio.h>
#include<math.h>
int const maxn=1001;
int dis,xi,yi,n,flag=0;
int ii[4]={1,-1,0,0};
int jj[4]={0,0,1,-1};
int f[maxn][maxn]={0};
struct
{
int step,x,y,dis;
}s[maxn*maxn];
void work(int a,int b)
{
int i,k,xx,yy;
if(a==xi&&b==yi)
{
flag=1;
return;
}
for(k=0;k<4;k++)
{
xx=a+ii[k];
yy=b+jj[k];
if((xx<maxn&&xx>=0)&&(yy>=0&&yy<maxn)&&(f[xx][yy]==0))
{
int dd;
if(xx==xi&&yy==yi)
{
flag=1;
return;
}
for(i=tail;;i--)
if(s[i-1].dis>dd) s[i]=s[i-1];
else
{
s[i].x=xx;
s[i].y=yy;
s[i].dis=dd;
f[xx][yy]=1;
break;
}
tail++;
}
}
}
int main()
{
int i,j;
scanf("%d %d %d",&xi,&yi,&n);
while(n--)
{
scanf("%d%d",&i,&j);
f[i+500][j+500]=1;
}
s[0].x=500;
s[0].y=500;
s[0].step=0;
s[0].dis=abs(xi)+abs(yi);
xi+=500;
yi+=500;
f[500][500]=1;
{
if(flag) break;
}
return 0;
}```

Followed by: