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

回顾一下,搜索也很简单的嘛

Posted by wy54224 at 2011-04-16 21:45:55 on Problem 3984
var i,j,bj,closed,open,x,y:integer;
    a,df:array[0..6,0..6]of 0..1;
    b:array[1..100,1..2]of integer;
    c1,c2:array[0..6,0..6]of integer;
    d:array[1..100,1..2]of integer;
procedure pd(x1,y1:integer);
begin
if(a[x1,y1]=0)and(df[x1,y1]=0)then
begin
inc(closed);
b[closed,1]:=x1;b[closed,2]:=y1;
c1[x1,y1]:=x;c2[x1,y1]:=y;
df[x1,y1]:=1;
if(x1=5)and(y1=5)then bj:=1;
end;
end;
begin
fillchar(df,sizeof(df),0);
for i:=0 to 6 do
for j:=0 to 6 do a[i,j]:=1;
for i:=1 to 5 do
 for j:=1 to 5 do read(a[i,j]);
b[1,1]:=1;b[1,2]:=1;open:=0;closed:=1;bj:=0;
df[1,1]:=1;
repeat
inc(open);
x:=b[open,1];y:=b[open,2];
pd(x+1,y);
pd(x-1,y);
pd(x,y-1);
pd(x,y+1);
until bj=1;
x:=5;y:=5;open:=0;
repeat
inc(open);
d[open,1]:=x;d[open,2]:=y;
x:=c1[x,y];y:=c2[d[open,1],y];
until(x=1)and(y=1);
writeln('(0, 0)');
for closed:=open downto 1 do writeln('(',d[closed,1]-1,', ',d[closed,2]-1,')');
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator