175 条题解
-
0skyfinder LV 6 @ 2009-11-08 16:09:46
const d:array[1..4,1..2]of integer=((-1,0),(-1,-1),(0,-1),(0,0));
var f:array[0..100,1..50,1..50]of longint;
a:array[1..50,1..50]of integer;
i,j,k,k1,n,m:integer;function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;begin
readln(n,m);
for i:=1 to n do
begin
for j:=1 to m do read(a);
readln;
end;
for i:=2 to m+n-1 do
for j:=1 to i do
if j -
02009-11-07 15:04:26@
#include
using namespace std;int main(void)
{
int a[51][51];
int d[51][51][101];
int m , n;
cin >> m >> n;for(int i = 1 ; i a[i][j];
for(int j = 0 ; j -
02009-11-05 22:36:28@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 212ms
├ 测试数据 08:答案正确... 274ms
├ 测试数据 09:答案正确... 352ms
├ 测试数据 10:答案正确... 306ms
---|---|---|---|---|---|---|---|-Accepted 有效得分:100 有效耗时:1144ms
编了一个4维DP、、其实可以降到三维
-
02009-11-04 12:51:50@
二维数组顺利AC
program massage;
var i,j1,j2,n,m,k1,k2:longint;
a:array[0..120,0..120]of longint;
f1,f2:array[0..120,0..120]of longint;function max(a,b,c,d:longint):longint;
var i:longint;
begin
i:=a;
if b>i then i:=b;
if c>i then i:=c;
if d>i then i:=d;
max:=i;
end;begin
readln(m,n);
for i:=1 to m do begin
for j1:=1 to n do
read(a);
readln;
end;
k2:=0;
for i:=1 to m+n-1 do begin
inc(k2);
if k2>n then k2:=n;
k1:=i-m+1;
if k1 -
02009-11-04 12:50:53@
不大清楚
-
02009-11-03 23:11:09@
为什么由f[1,1,1,1]到f[m,n,m,n]的答案与f[1,1,m,n]到f[m,n,1,1]的答案不一样?我的样例答案大了1。难道是我写错了么?
-
02009-11-07 11:14:35@
郁闷,竟然没有一次ac,
失败啊,失败~~~ -
02009-11-02 16:58:26@
#include
using namespace std;
int f[51][51][100];
int a[51][51];
int m,n,i,j,k;
int max4(int x1,int x2,int x3,int x4){
return max(x4,max(x3,max(x2,x1)));
}
int main()
{
memset(f,0,sizeof(f));
memset(a,0,sizeof(a));
cin>>m>>n;
for(i=1;ia[i][j];
}
}
for(k=1;k -
02009-11-01 15:54:26@
var
f : array[0..200,0..200]of longint;
map : array[0..200,0..200]of longint;
i, j, l, m, n, ans : longint;
function max(a,b,c,d:longint):longint;
begin
max := a;
if max < b then max := b;
if max < c then max := c;
if max < d then max := d;
end;
begin
readln(m,n);
for i := 1 to m do
for j := 1 to n do read(map);
fillchar(f,sizeof(f),0);
for i := 2 to n+m-1 do
for j := i-1 downto 1 do
for l := i downto j+1 do
f[j,l] := max(f[j,l],f[j-1,l-1],f[j-1,l],f[j,l-1])+map+map;
ans := f[n-1,n];
writeln(ans);
end.下面的大牛怎么都三维的, 什么意思,不明白,只会二维的, 囧~~~
orz三维神牛,希望具体讲解讲解 -
02009-10-31 15:07:54@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms为什么我去年没去……可惜了
-
02009-10-30 14:27:54@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 25ms
├ 测试数据 07:答案正确... 369ms
├ 测试数据 08:答案正确... 494ms
├ 测试数据 09:答案正确... 634ms
├ 测试数据 10:答案正确... 588ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:2110ms这样也能AC?!
Var
s : array[-1..55,-1..55]of longint;
f : array[-1..55,-1..55,-1..55,-1..55]of longint;
m,n,i,j,ii,jj : word;Function max(a,b,c,d : longint) : longint;
begin
if a>b then b:=a ;if c>b then b:=c ;if d>b then b:=d;
exit(b);
end;Begin
readln(n,m);fillchar(s,sizeof(s),0);fillchar(f,sizeof(f),0);
for i := 1 to n do
begin for j := 1 to m do read(s);readln; end;
for i := 1 to n do
for j := 1 to m do
for ii:= 1 to n do
for jj:= 1 to m do
if (iii)or(jjj)then
f :=max(f,f,f,f)+s[ii,jj]+s
else f :=max(f,f,f,f)+s;
writeln(f[n,m,n,m]);
End. -
02009-10-29 21:31:03@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms改装了大牛的程序!其实不是大牛
-
02009-10-29 11:32:13@
program p1493;
var
map:array[0..51,0..51]of longint;
a:array[0..101,0..101]of longint;
dp:array[0..101,0..101,0..101]of longint;
i,j,p,q,k,t1,t2,m,n,len:longint;
flag:array[0..101,0..101]of boolean;
procedure work(p,q,k,t1,t2:longint);
begin
if dp[p,q,k]2 then
begin t1:=q+1;t2:=k-1;work(p,q,k,t1,t2);end;
t1:=q-1;t2:=k+1;work(p,q,k,t1,t2);
t1:=q+1;t2:=k+1;work(p,q,k,t1,t2);
end;
writeln(dp[len-1,n-1,n+1]);
end. -
02009-10-26 19:12:25@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
以这个AC纪念挂了一位大牛和我的题目.郁闷!哎!
人生啊!凄惨啊!考原题就算了,非要搞个倒过来去的,害死我了! -
02009-10-26 18:19:06@
program p1493;
var f:array[0..100,0..50,0..50] of longint;
a:array[1..50,1..50] of longint;
i,j,k,n,m:longint;
max:array[1..4] of longint;function max1(i1,i2,i3,i4,i5:longint):longint;
begin
exit(f[i5,i1,i3]);
end;function max2:longint;
var i:longint;
begin
max2:=-1;
for i:=1 to 4 do if max[i]>max2 then max2:=max[i];
end;begin
readln(m,n);
for i:=1 to m do
for j:=1 to n do read(a);
for k:=1 to m+n-1 do
for i:=1 to m do
for j:=1 to m do begin
if (k-j>=0) and (k-i>=0) then begin
filldword(max,sizeof(max) div 4,0);
if (i>1) and (j>1) then max[1]:=max1(i-1,k-i+1,j-1,k-j+1,k-1);
if (i>1) and (k-j>0) then max[2]:=max1(i-1,k-i+1,j,k-j,k-1);
if (k-i>0) and (j>1) then max[3]:=max1(i,k-i,j-1,k-j+1,k-1);
if (k-i>0) and (k-j>0) then max[4]:=max1(i,k-i,j,k-j,k-1);
f[k,i,j]:=max2;
if (i=j) then f[k,i,j]:=f[k,i,j]+a else f[k,i,j]:=f[k,i,j]+a+a[j,k-j+1];
end;
end;
writeln(f[m+n-1,m,m]);
end. -
02009-10-25 12:35:13@
program st1;
var m,n,i,j,k:longint;
a:array[0..50,0..50] of longint;
f:array[0..100,0..51,0..51] of longint;
function max(x1,x2,x3,x4:longint):longint;
begin
if x2>x1 then x1:=x2;
if x3>x1 then x1:=x3;
if x4>x1 then x1:=x4;
max:=x1;
end;
begin
readln(m,n);
for i:=1 to m do begin
for j:=1 to n do read(a);
readln;
end;
f[1,1,2]:=a[1,2]+a[2,1];
for i:=2 to n+m-3 do
for j:=1 to n-1 do begin
if (j>i+1)or(i+2-j>m) then continue;
for k:=j+1 to n do begin
if (k>i+1)or(i+2-k>m) then continue;
f:=max(f,f,f,f)+a[j,i+2-j]+a[k,i+2-k];
end;
end;
writeln(f[n+m-3,n-1,n]);
end.
请大牛帮忙看看哪里错了,为什么只有60分。 -
02009-10-24 20:25:18@
首先,我想说这个传纸条是让我非常气愤的题目,特别是在去年的比赛中。
所以我很快的把它给过了
另外,我发现许多发题解的人十分没有道德,发这么多程序和ac记录让我开起来都这么慢 -
02009-10-23 22:58:49@
const int limitSize = 60;
int m, n;
int mat[limitSize][limitSize];
int opt[limitSize = m || x2 < 0 || x2 >= m )
return -1;
if ( y1 < 0 || y1 >= n || y2 < 0 || y2 >= n )
return -1;
if ( p == ( m - 1 ) + ( n - 1 ) ) return 0;
if ( p && x1 == x2 ) return -1;
if ( opt[p][x1][x2] >= 0 ) return opt[p][x1][x2];
int &ret = opt[p][x1][x2];
ret = 0;
for ( int v = 0; v < 4; v++){
int tmp = Calc( p+1, x1 + v % 2, x2 + v / 2 );
if ( tmp > ret ) ret = tmp;
}
ret += mat[x1][y1] + mat[x2][y2];
return ret;
} -
02009-10-21 17:31:15@
郁闷。。原本很容易理解的3重硬是被我写复杂。。。还WA了一次。。
我是把转移方程对角线前和对角线后。。。大概不用这样。。。悲剧。。。准备三取了。。
var a,b:array[-1..101,-1..101] of longint;
lo:array[1..200] of longint;
f:array[0..200,-1..100,-1..100] of longint;
i,j,k,l,m,n,x,y:longint;
function max(x,y:longint):longint;
begin
if x>y then exit(x) else exit(y);
end;begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do
read(a);for k:=1 to m do
begin
x:=1;y:=k;l:=0;
while (y>0) and (x0) and (x -
02009-10-21 15:45:51@
傻傻的4重循环 改 3重循环……
数组越界 WA 了我3次……
program message;
const maxn=52;
var
f:array[0..maxn,0..maxn,0..maxn,0..maxn]of longint;
i,j,k,l,n,m:longint;
g:array[0..maxn,0..maxn]of longint;
t:longint;
beginreadln(n,m);
for i:=1 to n do
begin
for j:=1 to m-1 do read(g);
readln(g);
end;
fillchar(f,sizeof(f),0);
for i:=1 to n do
for j:=1 to m do
for k:=1 to n do
begin
l:=i+j-k;
if (l>0)and(l0)and(lt then
t:=f+g+g[k,l];
if f+g+g[k,l]>t then
t:=f+g+g[k,l];
if f+g+g[k,l]>t then
t:=f+g+g[k,l];
if f+g+g[k,l]>t then
t:=f+g+g[k,l];
if (i=n)and(j=m)and(k=n)and(l=m) then f:=t
else if (i=k)and(j=l)then f:=-9999
else f:=t;
end;
end;
writeln(f[n,m,n,m]);end.