讨论 / 双线程怎么只有60分,麻烦大牛们帮忙找找
nxyz117zhouzhe 2011-11-08 05:41:00
点我顶贴 收藏 删除
var f:array [0..11,0..11,0..11,0..11] of longint;

x,y,s,n,i1,i2,j1,j2:longint;

a:array [0..11,0..11] of longint;

begin

readln(n);

readln(x,y,s);

while not ((x=0) and (y=0) and (s=0)) do

begin

a[x,y]:=s;

readln(x,y,s);

end;

fillchar(f,sizeof(f),0);

for i1:=1 to n do

for j1:=1 to n do

for i2:=1 to n do

for j2:=1 to n do

begin

f[i1,j1,i2,j2]:=0;

if i1-1>0 then

if (i2-1>0) and (f[i1-1,j1,i2-1,j2]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1-1,j1,i2-1,j2]

else if (j2-1>0) and (f[i1-1,j1,i2,j2-1]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1-1,j1,i2,j2-1];

if j1-1>0 then

if (i2-1>0) and (f[i1,j1-1,i2-1,j2]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1,j1-1,i2-1,j2]

else if (j2-1>0) and (f[i1,j1-1,i2,j2-1]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1,j1-1,i2,j2-1];

if (i1=i2) and (j1=j2) then inc(f[i1,j1,i2,j2],a[i1,j1])

else inc(f[i1,j1,i2,j2],a[i1,j1]+a[i2,j2]);

end;

writeln(f[n,n,n,n]);

end.

#1 nxyz117zhouzhe@2011-11-08 05:40:00
回复 删除
怎么这样就过了

for i1:=1 to n do

for j1:=1 to n do

for i2:=1 to n do

for j2:=1 to n do

begin

f[i1,j1,i2,j2]:=0;

if (f[i1-1,j1,i2-1,j2]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1-1,j1,i2-1,j2];

if (f[i1-1,j1,i2,j2-1]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1-1,j1,i2,j2-1];

if (f[i1,j1-1,i2-1,j2]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1,j1-1,i2-1,j2];

if (f[i1,j1-1,i2,j2-1]>f[i1,j1,i2,j2])

then f[i1,j1,i2,j2]:=f[i1,j1-1,i2,j2-1];

if (i1=i2) and (j1=j2) then inc(f[i1,j1,i2,j2],a[i1,j1])

else inc(f[i1,j1,i2,j2],a[i1,j1]+a[i2,j2]);

end;

#2 nxyz117zhouzhe@2011-11-08 05:41:00
回复 删除
不懂

为什么不能判断

查看更多回复
提交回复