题解

174 条题解

  • 0
    @ 2009-05-10 17:19:02

    var

    n,m,i,j,k,t,o,u:longint;

    ans:int64;

    p:array[0..100,0..501] of boolean;

    a,b,f:array[0..100,0..500] of int64;

    s:array[1..50000] of longint;

    function min(a,b:int64):int64;

    begin

    if a

  • 0
    @ 2009-05-07 13:35:36

    var

    n,m,i,j,k,t,o,u:longint;

    ans:int64;

    p:array[0..100,0..501] of boolean;

    a,b,f:array[0..100,0..500] of int64;

    s:array[1..50000] of longint;

    function min(a,b:int64):int64;

    begin

    if a

  • 0
    @ 2009-05-05 21:11:42

    太猥琐了 我一直以为INT64没多大 随手把MIN的初值弄成1000000000

    结果一直错 我日啊

  • 0
    @ 2009-04-20 10:32:51

    一次秒杀!

  • 0
    @ 2009-04-15 12:40:22

    "请输出最短的路径"

    为什么???

    我的AC率!!!

  • 0
    @ 2009-04-13 14:26:42

    意思是

    如果从下面来的代价

  • 0
    @ 2009-04-06 20:13:03

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

    Program ural_1029_ministry;

    Type pp=record

    i,j:integer;

    End;

    Var path:array[1..100,1..500]of pp;//path数组存储第房的前趋结点

    f,a:array[1..100,1..500]of longint;

    ans:array[1..50000]of integer;

    n,m,i,j:longint;

    t:longint;

    Begin

    readln(m,n);

    for i:=1 to m do

    begin

    for j:=1 to n do

    read(a);

    readln;

    end;

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

    for j:=1 to n do f[1,j]:=a[1,j];

    for i:=2 to m do//递推楼层数

    begin

    for j:=1 to n do//改房间的物品直接从正楼下的房子传上来,每个房子只有一种情况

    begin

    f:=f+a;

    path.i:=i-1;path.j:=j;

    end;

    for j:=2 to n do//物品从左方同一楼层的左方传来

    begin

    t:=f+a;//注意这里要先用t存储最小值,最后才将t放入f中

    if t

  • 0
    @ 2009-04-04 00:26:52

    void work()

    {

    for(int i=1;i=1;j--)

    if(f[i][j+1]+(long long)map[i][j]

  • 0
    @ 2009-04-02 17:47:40

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2009-04-02 11:42:39

    program p1139(input,output);

    var

    a:array[1..200,1..600] of longint;

    f,sum:array[0..200,0..600] of int64;

    g:array[1..200,1..600,1..2] of longint;

    n,m,i,j,b,t,p:longint;

    k:int64;

    procedure print(x,y:longint);

    var

    i:longint;

    begin

    if x=1 then

    begin

    writeln(y);

    exit;

    end

    else if x=g[x,y,1] then

    begin

    print(g[x,y,1],g[x,y,2]);

    for i:=g[x,y,2]+1 to y do

    writeln(i);

    for i:=g[x,y,2]-1 downto y do

    writeln(i);

    end

    else

    begin

    print(g[x,y,1],g[x,y,2]);

    writeln(y);

    end;

    end;

    begin

    read(n,m);

    for i:=1 to n do

    for j:=1 to m do

    read(a);

    for i:=1 to m do

    f[1,i]:=a[1,i];

    for i:=1 to n do

    begin

    sum:=a;

    for j:=2 to m do

    sum:=sum+a;

    end;

    for i:=2 to n do

    begin

    for t:=1 to m do

    begin

    f:=f+a;

    g:=i-1;

    g:=t;

    end;

    for j:=1 to m do

    begin

    b:=0;

    for t:=1 to j-1 do

    if f>f+(sum-sum) then

    begin

    b:=1;

    break;

    end;

    if b=1 then continue;

    for t:=j+1 to m do

    if f>f+(sum-sum) then

    begin

    b:=1;

    break;

    end;

    if b=1 then continue;

    for t:=j-1 downto 1 do

    if f>=f+sum-sum then

    begin

    f:=f+sum-sum;

    g:=i;

    g:=j;

    end;

    for t:=j+1 to n do

    if f>=f+sum-sum then

    begin

    f:=f+sum-sum;

    g:=i;

    g:=j;

    end;

    end;

    end;

    k:=0;

    for i:=1 to m do

    if (f[n,i]

  • 0
    @ 2009-03-31 12:35:08

    求求大牛该怎麽改; 谢谢。

    编译通过...

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

    ├ 测试数据 02:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 03:答案错误...程序输出比正确答案长

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

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

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

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

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

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

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

    Unaccepted 有效得分:67 有效耗时:0ms

    program P1139;

    var

    m,n,i,j,min,x,y :longint;

    map :array[1..100,1..500]of longint;

    ans :array[1..100,1..500]of longint;

    line :array[1..50000]of integer;

    procedure print;

    var

    i,j,t,k :longint;

    begin

    t:=0; k:=0;

    while (x0) do

    begin

    if (yn) and (ans[x,y]-map[x,y]=ans[x,y+1]) then

    begin

    inc(t); line[t]:=y; y:=y+1; continue;

    end;

    if (y1) and (ans[x,y]-map[x,y]=ans[x,y-1]) then

    begin

    inc(t); line[t]:=y; y:=y-1; continue;

    end;

    if (x1) and (ans[x,y]-map[x,y]=ans[x-1,y]) then

    begin

    inc(t); line[t]:=y; x:=x-1; continue;

    end;

    inc(k);

    if k=2 then begin inc(t); line[t]:=y; break; end;

    end;

    for i:=t downto 1 do writeln(line[i]);

    end;

    procedure work;

    begin

    for i:=1 to m do

    begin

    for j:=1 to n do

    begin

    if (jn) and (ans>ans+map) then

    ans:=ans+map;

    if (j1) and (ans>ans+map) then

    ans:=ans+map;

    if (im) and (ans>ans+map) then

    ans:=ans+map;

    end;

    for j:=n downto 1 do

    begin

    if (jn) and (ans>ans+map) then

    ans:=ans+map;

    if (j1) and (ans>ans+map) then

    ans:=ans+map;

    if (im) and (ans>ans+map) then

    ans:=ans+map;

    end;

    end;

    min:=maxlongint;

    for i:=1 to n do if ans[m,i]

  • 0
    @ 2009-03-21 22:44:02

    给个小链接..# 我在那里第6个点爆了...#

    http://acm.timus.ru/forum/?space=1&num=1029...

  • 0
    @ 2009-03-22 16:46:52

    编译通过...

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

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

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

    ├ 测试数据 04:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

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

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

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

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

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

    Unaccepted 有效得分:78 有效耗时:0ms

    该怎么改...

  • 0
    @ 2009-03-14 21:28:38

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

    ├ 测试数据 02:运行超时...

    ├ 测试数据 03:运行超时...

    ├ 测试数据 04:运行超时...

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:运行超时...

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

    ├ 测试数据 08:运行超时...

    ├ 测试数据 09:运行超时...

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

    Unaccepted 有效得分:22 有效耗时:0ms

    怎么会有8个数据超时?

    我的思路是:

    ①一楼必定走到二楼的对应房号的房间(最优)。

    ②最高楼层必定从第二高的对应房号的房间走到,因为每层只要走到即可(最优)。

    ③问题就剩下中间楼层也要走到最优了。

    f[i][j]=min(f的每一个位置走到f[i][j]的最小值啦)(最优)

    可是竟然8个数据超时,有人能指点一下吗?

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

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

    ├ 测试数据 02:运行超时...

    ├ 测试数据 03:运行超时...

    ├ 测试数据 04:运行超时...

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:答案错误...程序输出比正确答案长

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

    ├ 测试数据 08:答案错误...程序输出比正确答案长

    ├ 测试数据 09:运行超时...

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

    Unaccepted 有效得分:22 有效耗时:0ms

    这是逆向读数据,顺向操作。减少了最后的逆向判断的相关操作后的结果。

    ╮(╯▽╰)╭

    ├ 测试数据 01:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 02:运行超时...

    ├ 测试数据 03:运行超时...

    ├ 测试数据 04:运行超时...

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:答案错误...程序输出比正确答案长

    ├ 测试数据 07:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 08:答案错误...程序输出比正确答案长

    ├ 测试数据 09:运行超时...

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

    Unaccepted 有效得分:0 有效耗时:0ms

    崩溃了

  • 0
    @ 2009-03-11 17:14:34

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

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

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

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

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

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

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

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

    ├ 测试数据 09:答案错误...程序输出比正确答案长

    oh,what a fuck....

  • 0
    @ 2009-02-27 22:22:51

    water..居然没发现。

    AC流程:

    打开gmail——>搜索邮件 ural 1029——>打开附件——>Ctrl+A

    ——>Ctrl+C——>点击提交——>Ctrl+V——>提交——>AC

  • 0
    @ 2009-02-24 21:01:58

    这题也太jzp了吧

  • 0
    @ 2009-02-14 17:18:15

    强烈鄙视这道题 这是我所见的最猥琐的题

    大家一定要将数组开到int64啊

  • 0
    @ 2009-02-13 21:07:17

    为什么采药难度是2 而这题难度是1啊?我觉得比采药难啊

  • 0
    @ 2009-02-08 17:44:56

    双向~

    顺序~

    感谢各位大牛~~

信息

ID
1139
难度
7
分类
动态规划 点击显示
标签
递交数
5206
已通过
858
通过率
16%
被复制
7
上传者