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 |
改了之后,一直WA,然而应该并没有错const px:array[1..8] of -2..2=(-1,1,1,-1,-2,2,2,-2); py:array[1..8] of -2..2=(-2,-2,2,2,-1,-1,1,1); var flag:array[0..100,0..100] of boolean; road:array[1..100,1..2] of integer; n,p,q,m:integer; check:boolean; procedure pre(p,q:integer); var i,j:integer; begin fillchar(flag,sizeof(flag),false); fillchar(road,sizeof(road),0); for i:=1 to q do for j:=1 to p do flag[i,j]:=true; road[1,1]:=1; road[1,2]:=1; flag[1,1]:=false; end; procedure print(k:integer); var i:integer; begin check:=false; for i:=1 to k do write(chr(road[i,1]+64),road[i,2]); writeln; end; procedure dfs(x,y,k:integer); var i,nx,ny:integer; begin if k=p*q then print(k) else for i:=1 to 8 do begin nx:=x+px[i]; ny:=y+py[i]; if (nx>0) and (nx<=q) and (ny>0) and (ny<=p) and flag[nx,ny] and check then begin road[k+1,1]:=nx; road[k+1,2]:=ny; flag[nx,ny]:=false; dfs(nx,ny,k+1); flag[nx,ny]:=true; end; end; end; begin readln(n); for m:=1 to n do begin readln(p,q); pre(p,q); check:=true; writeln('Scenario #',m,':'); dfs(1,1,1); if check then writeln('impossible'); writeln; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator