比赛 20140714上午练习 评测结果 AAAAAAAAAA
题目名称 冲出亚马逊之圣战前夜 最终得分 100
用户昵称 农场主 运行时间 0.007 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2014-07-14 11:09:49
显示代码纯文本
var
s:array[0..101,0..101] of integer;
a:string;
mix,n,i,j,m:integer;
procedure v(x,y:integer);
var
i:integer;
begin
if (x<>n)or(y<>n) then
begin
s[x,y]:=-1;
if (s[x+1,y]=0)or(s[x+1,y]=2)or(s[x+1,y]=5) then begin mix:=mix+1; v(x+1,y); end;
if (s[x-1,y]=0)or(s[x-1,y]=2)or(s[x-1,y]=5) then begin mix:=mix+1; v(x-1,y); end;
if (s[x,y+1]=0)or(s[x,y+1]=2)or(s[x,y+1]=5) then begin mix:=mix+1; v(x,y+1); end;
if (s[x,y-1]=0)or(s[x,y-1]=2)or(s[x,y-1]=5) then begin mix:=mix+1; v(x,y-1); end;
end else begin m:=1; s[n,n]:=-1; end;
end;

begin
assign(input,'ymxpre.in');
assign(output,'ymxpre.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(a);
for j:=1 to n do
s[i,j]:=ord(a[j])-ord('0');
end;
for i:=0 to n+1 do begin s[0,i]:=-1; s[i,0]:=-1; s[i,n+1]:=-1; s[n+1,i]:=-1;  end;
if (s[1,1]=0)or(s[1,1]=2)or(s[1,1]=5)
then begin mix:=1; v(1,1); end;
if m=1 then writeln('yes') else writeln('no');
writeln(mix);
close(input); close(output);
end.