比赛 noip-081029 评测结果 WAWWWTTTTT
题目名称 取数字问题 最终得分 10
用户昵称 WaterFire 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-29 19:48:17
显示代码纯文本
program waterfire;
const
fin='number.in';
fout='number.out';
var
num:array[0..1000] of longint;
i,j,t,n,m,k,minnum:longint;
f,data:array[0..100,0..100] of longint;
f1,f2:text;
Procedure sear(a,b:longint);
var
ii,jj:longint;
Begin
 k:=k+data[a,b];
if (a=m)and(b=n) then
 begin
  num[t]:=k;
  inc(t);
 end else
if (a=m)and(b<>n) then
begin
inc(b);
sear(a,b);
k:=k-data[a,b];
dec(b);
end
else if (b=n)and(a<>m) then
begin
inc(a);
sear(a,b);
k:=k-data[a,b];
dec(a);
end else
begin
inc(b);
sear(a,b);
k:=k-data[a,b];
dec(b);
inc(a);
sear(a,b);
k:=k-data[a,b];
dec(a);
end;
End;

BEGIN
minnum:=maxlongint;
assign(f1,fin);reset(f1);
assign(f2,fout);rewrite(f2);
readln(f1,n,m);
t:=1;
for i:=1 to m do begin
 for j:=1 to n do
  read(f1,data[i,j]);
  readln(f1);
end;
sear(1,1);
for i:=1 to t do
 if (num[i]<minnum)and(num[i]>0) then
   minnum:=num[i];
 write(f2,minnum);
 close(f1);close(f2);
 END.