平面覆盖
题目大意:一个无限大的平面,给你N种行走方式,从原点出发,能不能走遍整个平面。
其实只要能走到(-1,0)(0,-1)(1,0)(0,1)四个点就可以了,可以推测只要在(-100,-100)(100,100)这个正方形里面走就可以了(为什么啊。。。)
program neayo; var i,j,k,n,xx,yy,top,closed:longint; x,y:array[0..11]of longint; qx,qy:array[0..50000]of longint; h:array[-100..100,-100..100]of boolean; begin assign(input,'walk.in');assign(output,'walk.out'); reset(input);rewrite(output); readln(n); while n<>0 do begin fillchar(h,sizeof(h),false); for i:=1 to n do read(x[i],y[i]); qx[1]:=0;qy[1]:=0; top:=0;closed:=1;h[0,0]:=true; repeat inc(top); xx:=qx[top]; yy:=qy[top]; for i:=1 to n do if (xx+x[i]>=-100)and(xx+x[i]<=100)and(yy+y[i]<=100)and(yy+y[i]>=-100) and(not h[xx+x[i],yy+y[i]])then begin h[xx+x[i],yy+y[i]]:=true; inc(closed); qx[closed]:=xx+x[i]; qy[closed]:=yy+y[i]; end; until(top>=closed); if (h[-1,0])and(h[1,0])and(h[0,-1])and(h[0,1])then writeln('YES') else writeln('NO'); readln(n); end; end.