完美超时

评测结果
编译成功

Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
Linking foo.exe
73 lines compiled, 0.0 sec , 29472 bytes code, 1628 bytes data
测试数据 #0: TimeLimitExceeded, time = 1015 ms, mem = 460 KiB, score = 0
测试数据 #1: TimeLimitExceeded, time = 1015 ms, mem = 460 KiB, score = 0
测试数据 #2: TimeLimitExceeded, time = 1015 ms, mem = 460 KiB, score = 0
测试数据 #3: TimeLimitExceeded, time = 1015 ms, mem = 460 KiB, score = 0
测试数据 #4: TimeLimitExceeded, time = 1015 ms, mem = 460 KiB, score = 0
测试数据 #5: TimeLimitExceeded, time = 1015 ms, mem = 468 KiB, score = 0
测试数据 #6: TimeLimitExceeded, time = 1015 ms, mem = 468 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 1015 ms, mem = 468 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 1015 ms, mem = 468 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 1015 ms, mem = 468 KiB, score = 0
TimeLimitExceeded, time = 10150 ms, mem = 468 KiB, score = 0
代码
program exercise(input,output);
type arr=array[0..17,0..17]of longint;
var n,m,r,c,ans:longint;
map:arr;
procedure readin;
var i,j:longint;
begin
readln(n,m,r,c);
ans:=maxlongint;
for i:=1 to n do
begin
for j:=1 to m do
read(map[i,j]);
readln;
end;
end;
function min(x,y:longint):longint;
begin
if x<y then
exit(x);
exit(y);
end;
procedure count(x,y:longint;f:arr);
var p:arr;
i,j,k,l:longint;
begin
fillchar(p,sizeof(p),0);
if x>r then
for i:=1 to x do
begin
for k:=1 to x do
begin
if k<i then
for l:=1 to y do
p[k,l]:=f[k,l];
if k>i then
for l:=1 to y do
p[k-1,l]:=f[k,l];
end;
count(x-1,y,p);
end;
if y>c then
for j:=1 to y do
begin
for k:=1 to y do
begin
if k<j then
for l:=1 to x do
p[l,k]:=f[l,k];
if k>j then
for l:=1 to x do
p[l,k-1]:=f[l,k];
end;
count(x,y-1,p);
end;
if (x=r)and(y=c) then
begin
l:=0;
for i:=1 to x do
for j:=1 to y do
begin
if i<x then
l:=l+abs(f[i,j]-f[i+1,j]);
if j<y then
l:=l+abs(f[i,j]-f[i,j+1]);
end;
ans:=min(ans,l);
end;
end;
begin
readin;
count(n,m,map);
writeln(ans);
end.

1 条评论

  • 1

信息

ID
1914
难度
4
分类
(无)
标签
递交数
951
已通过
366
通过率
38%
被复制
11
上传者