题解

157 条题解

  • 0
    @ 2009-10-10 13:07:05

    program dfx;

    const dx:array[1..2]of integer=(-1,0);

    var

    i,j,k,l,n,i1,j1,k1,l1,x,y,z,m1,m2:longint;

    f:array[0..1,0..30,0..30,0..30]of longint;

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

    function max(U,v:longint):longint;

    begin if u>v then exit(U) else exit(V); end;

    begin

    read(n);

    for i:=1 to n do for j:=1 to n do read(a);

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

    f[1,1,2,3]:=a[1,3]+a[2,2]+a[3,1]+a[1,1]+a[1,2]+a[2,1];

    m1:=1; m2:=0;

    for i:=2 to n*2-5 do begin

    m1:=1-m1; m2:=1-m2;

    for j:=1 to n do if jn)or (y>n) or (z>n) then

    else

    f[m1,j,k,l]:=max(f[m1,j,k,l],f[m2,x,y,z]+

    a[j,i+3-j]+a[k,i+3-k]+a[l,i+3-l]);

    end;

    end

    else break;

    end;

    write(f[m1,n-2,n-1,n]+a[n-1,n]+a[n,n-1]+a[n,n]);

    end.

    ps:短小精悍

    第100题!!

  • 0
    @ 2009-10-07 21:32:54

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    看了大牛的题解,终于懂了!!

  • 0
    @ 2009-10-05 20:40:18

    (Logic Determination !!) Attention!!

    if(i==k) f[i][j][k][l]+=(g[i][j]+g[l]);

    else

    if(k==l) f[i][j][k][l]+=(g[i][j]+g[k]);

    else

    f[i][j][k][l]+=(g[i][j]+g[k]+g[l]);

  • 0
    @ 2009-10-02 10:54:47

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2009-09-28 13:26:55

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2009-09-26 08:36:05

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var n,m,p,i,j,k,x1,y1,x2,y2,x3,y3:integer;

    sum:longint;

    a:array[0..20,0..20]of integer;

    f:array[0..50,0..20,0..20,0..20]of longint;

    function max(q,w,e,r,t,y,u,x:longint):longint;

    begin

    if q>w then max:=q else max:=w;

    if e>max then max:=e;

    if r>max then max:=r;

    if t>max then max:=t;

    if y>max then max:=y;

    if u>max then max:=u;

    if x>max then max:=x;

    end;

    function min(q,w:integer):integer;

    begin

    if q>w then min:=w else min:=q;

    end;

    begin

    readln(n);

    m:=n;

    for i:=1 to n do

    for j:=1 to m do

    read(a);

    f[3,1,2,3]:=a[1,1]+a[1,2]+a[2,1]+a[1,3]+a[2,2]+a[3,1];

    k:=m+n-1;

    for i:=4 to k-2 do

    begin

    if i

  • 0
    @ 2009-09-23 23:25:00

    program er;

    const dd:array[1..8,1..3] of integer=

    ((0,0,0),(-1,0,0),(0,-1,0),(0,0,-1),

    (-1,-1,0),(-1,0,-1),(0,-1,-1),(-1,-1,-1));

    var dp:array[1..21,0..21,0..21,0..21] of longint;

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

    l,r:array[0..1] of longint;

    i,i1,i2,i3,j,k,m,n,e:longint;

    function ok(a,b,c:longint):boolean;

    begin

    ok:=true;

    if (ar[1-e]) then exit(false);

    if (br[1-e]) then exit(false);

    if (cr[1-e]) then exit(false);

    end;

    function jishu(a1,b,c:longint):longint;

    begin

    if (a1=b)and(b=c)and(a1=c) then jishu:=a[k-a1+1,a1]

    else if a1=b then jishu:=a[k-a1+1,a1]+a[k-c+1,c]

    else if a1=c then jishu:=a[k-a1+1,a1]+a[k-b+1,b]

    else if b=c then jishu:=a[k-b+1,b]+a[k-a1+1,a1]

    else jishu:=a[k-a1+1,a1]+a[k-b+1,b]+a[k-c+1,c];

    end;

    begin

    read(n);

    for i:=1 to n do

    for j:=1 to n do

    read(a);

    dp[1,1,1,1]:=a[1,1];

    e:=0;l[e]:=1;r[e]:=1;

    for k:=2 to 2*n-1 do

    begin

    e:=1-e;

    if k=n then r[e]:=n else r[e]:=k;

    for i1:=l[e] to r[e] do

    for i2:=l[e] to r[e] do

    for i3:=l[e] to r[e] do

    for j:=1 to 8 do

    if ok(i1+dd[j,1],i2+dd[j,2],i3+dd[j,3]) then

    begin

    m:=jishu(i1,i2,i3);

    if dp[k,i1,i2,i3]

  • 0
    @ 2009-09-19 07:21:05

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    program p1143;

    var

    f:array[0..41,0..21,0..21,0..21] of longint;

    a,b:array[0..100,0..100] of integer;

    i,j,k,opt,n,x1,x2,x3,t,d:longint;

    function min(x,y:integer):integer;

    begin

    if x>y then x:=y;

    min:=x;

    end;

    function max(x,y:integer):integer;

    begin

    if xn then d:=1 else d:=-1;

    k:=(min(i,n)-max(i+1-n,1)+1);

    for x1:=1 to k do

    for x2:=x1 to k do

    for x3:=x2 to k do

    begin

    opt:=0;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if f>opt then opt:=f;

    if (x1=x2) and (x2=x3) then opt:=opt+a

    else if x1=x2 then opt:=opt+a+a

    else if x2=x3 then opt:=opt+a+a

    else opt:=opt+a+a+a;

    f:=opt;

    end;

    end;

    write(f[2*n-1,1,1,1]);

    end.

    WA了N次。。。。后来发现原来k>n与k

  • 0
    @ 2009-09-12 22:28:14

    ..这哪是原题..

  • 0
    @ 2009-09-07 18:44:25

    var a:array[0..21,0..21] of integer;

    f:array[0..41,0..21,0..21,0..21] of longint;

    i,j,n,k,s:integer;

    function max(q,w,e,r,t,y,u,o:longint):longint;

    begin

    max:=q;

    if w>max then max:=w;

    if e>max then max:=e;

    if r>max then max:=r;

    if t>max then max:=t;

    if y>max then max:=y;

    if u>max then max:=u;

    if o>max then max:=o;

    end;

    begin

    readln(n);

    for i:=1 to n do

    for j:=1 to n do read(a);

    for i:=0 to 1 do

    for j:=0 to 1 do

    for k:=0 to 1 do f[0,i,j,k]:=a[1,1];

    for s:=1 to 2*n-2 do

    for i:=1 to s+1 do

    for j:=1 to s+1 do

    for k:=1 to s+1 do

    begin

    f:=max(f,f,f,f,f,f,f,f)+a+a+a;

    if (i=j) and (ik) then f:=f-a

    else if (i=k) and (ij) then f:=f-a

    else if (ij) and (k=j) then f:=f-a

    else if (i=j) and (k=j) then f:=f-2*a;

    end;

    writeln(f[2*n-2,n,n,n]);

    end.

  • 0
    @ 2009-09-04 22:46:28

    60个AC!!

  • 0
    @ 2009-08-28 23:37:22

    Accepted 有效得分:100 有效耗时:0ms

    经典DP的变形

    和一取二取方格数差不多

  • 0
    @ 2009-08-26 14:57:52

    好题

    不会

    看题解

    懂了

    开始编

    错了

    查找

    数组小了!

    唉~

  • 0
    @ 2009-08-25 20:49:04

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    水题~~~~~

  • 0
    @ 2009-08-18 10:25:33

    我的O(n^6)程序竟然没超时.....但还是光荣了

    这是本人的超级沙茶程序:

    #include

    using namespace std;

    unsigned long long int f[21][21][21][21][21][21];

    int main()

    {int i,j,k,l,m,o,p,n,a[21][21],b[9];

    cin>>n;

    for(i=1;ia[i][j];

    }

    for(i=1;i

  • 0
    @ 2009-08-15 22:40:55

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    ---|---|---|---|---|---|---|---|---|---|---|---|--

    var f:array[0..20,0..20,0..20,0..39]of longint;

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

    i,j,k1,k2,k3,n:longint;

    function max(x1,x2,x3,x4,x5,x6,x7,x8:longint):longint;

    begin

    max:=x1;

    if max

  • 0
    @ 2009-08-15 12:29:43

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var

    map:array[1..20,1..20]of longint;

    dp:array[1..41,0..21,0..21,0..21]of longint;

    n,i,j,k,l1,l2,l3:longint;

    u:array[1..20,1..20]of longint;

    function max(a,b:longint):longint;

    begin

    if a>b then max:=a

    else max:=b;

    end;

    function s(i,l1,l2,l3:longint):longint;

    begin

    fillchar(u,sizeof(u),0);

    s:=0;

    if i

  • 0
    @ 2009-08-10 11:38:48

    {和传纸条一样只不过多了一些语句,数组多了一维}

  • 0
    @ 2009-08-04 20:46:47

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    可恶的多进程DP o(╯□╰)o|||

  • 0
    @ 2009-07-31 20:39:07

    要是再早一年做这题...

    我早就光荣退休了.

    ---|---|---|---|---|---|---|---|---|---|---|---|---|---|--

    • - 话说我们去年做过...还是死这了...

    ps:这题的程序那是相当的壮观...比去年的烂多了...

信息

ID
1143
难度
4
分类
动态规划 点击显示
标签
递交数
3507
已通过
1452
通过率
41%
被复制
9
上传者