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 |
其实很简单,代码写的好就一次ACconst dir=4; dx:array [1..dir] of longint=(1,-1,0,0); dy:array [1..dir] of longint=(0,0,1,-1); var m,n,k,i,j,l,x,y,ans,lt,rt:longint; dl,dr:array [0..32,0..32] of longint; vl,vr:array [0..32,0..32] of boolean; plx,ply,prx,pry:array [1..1024] of longint; a:array [0..1024,0..1024] of boolean; v:array [0..1024] of boolean; p:array [0..1024] of longint; function tonode(x,y:longint):longint; begin if (x+y) and 1=0 then begin if vl[x,y] then exit(dl[x,y]); vl[x,y]:=true; inc(lt);dl[x,y]:=lt; exit(lt); end else begin if vr[x,y] then exit(dr[x,y]); vr[x,y]:=true; inc(rt);dr[x,y]:=rt; exit(rt); end; end; function find(h:longint):boolean; var i:longint; begin for i:=1 to rt do if (a[h,i])and(not v[i]) then begin v[i]:=true; if (p[i]=0)or(find(p[i])) then begin p[i]:=h; exit(true); end; end; exit(false); end; begin open('input.txt','output.txt'); readln(m,n,k); for i:=1 to m do for j:=1 to n do if (i+j)and 1=0 then begin for l:=1 to dir do if (1<=i+dx[l])and(i+dx[l]<=m)and (1<=j+dy[l])and(j+dy[l]<=n) then a[tonode(i,j),tonode(i+dx[l],j+dy[l])]:=true; end; for i:=1 to k do begin readln(y,x); for l:=1 to dir do if (1<=x+dx[l])and(x+dx[l]<=m)and (1<=y+dy[l])and(y+dy[l]<=n) then begin if (x+y) and 1=0 then a[tonode(x,y),tonode(x+dx[l],y+dy[l])]:=false else a[tonode(x+dx[l],y+dy[l]),tonode(x,y)]:=false; end; end; for i:=1 to lt do begin fillchar(v,sizeof(v),false); if find(i) then inc(ans); end; if ans*2+k=m*n then writeln('YES') else writeln('NO'); endpro; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator