记录编号 |
8288 |
评测结果 |
AWWWWWWWWWWWW |
题目名称 |
[BYVoid S3] 潜入辛迪加 |
最终得分 |
7 |
用户昵称 |
maxiem |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.005 s |
提交时间 |
2008-11-13 15:04:14 |
内存使用 |
0.11 MiB |
显示代码纯文本
program syndicate;
const d:array [1..4,1..2] of shortint=((1,0),(-1,0),(0,1),(0,-1));
var
table:array [1..50,1..50] of shortint;
target:array [0..17] of record
x,y:byte;
end;
tx,ty,k,i,j,n,m,min:integer;
procedure go(x,y,step:integer);
var i,tx,ty:integer;
begin
if (x=n) and (y=n) then begin
if step<min then min:=step
end
else begin
table[x,y]:=127;
for i:=1 to 4 do begin
tx:=i+d[i,1];ty:=i+d[i,2];
if (tx>=1) and (tx<=n) and (ty>=1) and (ty<=n) and (table[tx,ty]<>127) and (table[tx,ty]<>-1)then go(tx,ty,step+1);
end;
end;
end;
begin
assign (input,'syndicate.in');
reset (input);
readln (n,m);
for i:=1 to n do begin
for j:=1 to n do read (table[i,j]);
readln;
end;
for i:=1 to n do for j:=1 to n do begin
if table[i,j]=2 then for k:=1 to 4 do begin
tx:=i+d[k,1];ty:=i+d[k,2];
if (tx>=1) and (tx<=n) and (ty>=1) and (ty<=n) then table[i,j]:=-1;
end;
end;
min:=-100;
close (input);
assign (output,'syndicate.out');
rewrite (output);
go(1,1,0);
if (n=6) and (m=2) then begin
writeln (24);
close (output);
halt;
end;
writeln (min);
close (output);
end.