比赛 20140714上午练习 评测结果 AAAAAAAAAA
题目名称 冲出亚马逊之圣战前夜 最终得分 100
用户昵称 miike is god 运行时间 0.003 s
代码语言 Pascal 内存使用 0.22 MiB
提交时间 2014-07-14 10:41:27
显示代码纯文本
var
a,b,n,k,ans:longint;
s:string;
z,z1:array[0..101,0..101]of longint;

procedure sousuo(x,y:longint);
var
i,j:longint;
begin
if (x=n)and(y=n) then
begin
writeln('yes');
k:=1;
end;
if ((z[x+1,y]=0)or(z[x+1,y]=2)or(z[x+1,y]=5))and(z1[x+1,y]=0) then
  begin
  z1[x+1,y]:=1;
  inc(ans);
  sousuo(x+1,y);
  end;
if ((z[x-1,y]=0)or(z[x-1,y]=2)or(z[x-1,y]=5))and(z1[x-1,y]=0) then
  begin
  z1[x-1,y]:=1;
  inc(ans);
  sousuo(x-1,y);
  end;
if ((z[x,y+1]=0)or(z[x,y+1]=2)or(z[x,y+1]=5))and(z1[x,y+1]=0) then
  begin
  z1[x,y+1]:=1;
  inc(ans);
  sousuo(x,y+1);
  end;
if ((z[x,y-1]=0)or(z[x,y-1]=2)or(z[x,y-1]=5))and(z1[x,y-1]=0) then
  begin
  z1[x,y-1]:=1;
  inc(ans);
  sousuo(x,y-1);
  end;
end;

begin
assign(input,'ymxpre.in');
assign(output,'ymxpre.out');
reset(input);
rewrite(output);

readln(n);
for a:=0 to 101 do
for b:=0 to 101 do
z[a,b]:=-1;
for a:=1 to n do
  begin
  readln(s);
  for b:=1 to n do
  z[a,b]:=ord(s[b])-48;
  end;
if (z[1,1]=1)or(z[1,1]=3)or(z[1,1]=4) then
  begin
  writeln('no');
  writeln('0');
  exit;
  end;
ans:=1;
z1[1,1]:=1;
sousuo(1,1);
if k=0 then writeln('no');
writeln(ans);
close(input);close(output);
end.