358 条题解

  • 0
    @ 2009-09-05 09:52:26

    var n,m,i,j:integer;

    max,max1:longint;

    a,f:array[0..501,0..501] of longint;

    procedure kid(x,y,l:longint);

    begin

    if f[x,y]>0 then begin if l+f[x,y]-1>max then max:=l+f[x,y]-1;exit;end

    else

    begin

    if (a[x-1,y]>0) and (a[x-1,y]0) and (a[x+1,y]0) and (a[x,y-1]0) and (a[x,y+1]max then max:=l;

    end;

    begin

    readln(n,m);

    for i:=1 to n do

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

    for i:=0 to m+1 do begin a[0,i]:=-1;a[n+1,i]:=-1;a:=-1;a:=-1;end;

    max1:=0;

    for i:=1 to n do

    for j:=1 to m do

    begin

    max:=0;

    kid(i,j,1);

    f:=max;

    if max>max1 then max1:=max;

    end;

    writeln(max1);

    end.

  • 0
    @ 2009-09-04 20:35:31

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    写QSORT+DP的同志注意。。。。

    很郁闷我第一次也是这样写。。。

    结果。。TLE 1 个点。。。

    可能是程序常数写得太大了。。

    程序效率还不够高。。。

    所以建议。。

    实在AC不了还是改写记忆化搜索吧。。

  • 0
    @ 2009-09-06 17:22:42

    qsort+DP:

    编译通过...

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

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

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

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

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

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

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

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

    ├ 测试数据 09:运行时错误...|错误号: 202

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

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

    Unaccepted 有效得分:80 有效耗时:25ms

    const s:array[1..4,1..2]of longint=((-1,0),(0,-1),(1,0),(0,1));

    var

    a,f:array[0..501,0..501]of longint;

    b:array[1..250000,0..2]of longint;

    r,c,i,j,k,min:longint;

    procedure qsort(l,r:longint);

    var i,j,x,y,z:longint;

    begin

    i:=l;j:=r;x:=b;y:=b;z:=b;

    while i

  • 0
    @ 2009-08-20 23:36:53

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

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

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

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

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

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

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

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

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

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

    qsort+dp。。。。。快排写腐了,,,提交n次。。。。。。郁闷。。。。。

  • 0
    @ 2009-08-20 15:39:43

    qsort+dp

    很简单,写了20分钟

    但调了一个晚上

    现在才发现是把max默认为到最大高度的长度了

    ...

  • 0
    @ 2009-08-17 15:05:37

    #include

    #define M 502

    typedef struct{

    int h,x,y;

    }a;

    int f[M][M],p[M][M];

    a map[250001],tmp;

    int kp(int p,int r)

    {

    int x,i,j;

    x = map[(p+r)/2].h;

    i = p;

    j = r;

    do {

    while(map[i].hp)j--;

    if(ip[map[i].x][map[i].y-1])

    f[map[i].x][map[i].y] = m(f[map[i].x][map[i].y],1+f[map[i].x][map[i].y-1]);

    if(map[i].y+1p[map[i].x][map[i].y+1])

    f[map[i].x][map[i].y] = m(f[map[i].x][map[i].y],1+f[map[i].x][map[i].y+1]);

    max = m(max,f[map[i].x][map[i].y]);

    }

    printf("%d",max);

    return 0;

    }

  • 0
    @ 2009-08-15 18:48:53

    数组开longint是常识好呗。。。dp+记忆化搜索不用排序,可以直接得到

    编译通过...

    ├ 测试数据 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-14 16:18:24

    编译通过...

    ├ 测试数据 01:运行时错误...|错误号: 128

    ├ 测试数据 02:运行时错误...|错误号: 128

    ├ 测试数据 03:运行时错误...|错误号: 128

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

    ├ 测试数据 05:运行时错误...|错误号: 128

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

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

    ├ 测试数据 08:运行时错误...|错误号: 128

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

    ├ 测试数据 10:运行时错误...|错误号: 128

    ........什么吗……

    谁帮我看看……(C++,动规+快排)

    #include

    using namespace std;

    long d[2][5]={0,1,-1,0,0,0,0,0,1,-1};//增量数组

    long map[50001][4]={};

    long r,c;

    void swap(long x,long y){

    long t;

    t=map[x][0];

    map[x][0]=map[y][0];

    map[y][0]=t;

    t=map[x][1];

    map[x][1]=map[y][1];

    map[y][1]=t;

    t=map[x][2];

    map[x][2]=map[y][2];

    map[y][2]=t;

    }

    void qsort(long start,long end){

    long i=start;

    long j=end;

    long mid=map[(i+j)/2][0];//选取中间位置数

    while(ic;

    for(long i=1;imap[(i-1)*r+j][0];

    map[(i-1)*r+j][1]=i;

    map[(i-1)*r+j][2]=j;

    }

    qsort(1,r*c);

    for(long i1=r*c;i1>=1;i1--){

    for(long i2=r*c;i2>=1;i2--){

    for(long j=1;j

  • 0
    @ 2009-08-09 22:43:01

    我真想揍死出第9个点的人。太猥琐了。。。

    想到过全出一样的高度,没想到要用longint的高度。。。

  • 0
    @ 2009-08-09 13:06:03

    水题 简单的DP

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    i,j,r,c,max:longint;

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

    function find(i,j:integer):longint;

    var

    now:longint;

    begin

    if f-1 then find:=f

    else

    begin

    now:=0;

    if (i-1>=1)and(anow) then now:=find(i-1,j);

    if (i+1=1)and(anow) then now:=find(i,j-1);

    if (j+1max then max:=find(i,j);

    write(max);

    end.

  • 0
    @ 2009-08-08 12:42:46

    编译通过...

    ├ 测试数据 01:运行时错误...|错误号: -1073741571

    ├ 测试数据 02:运行时错误...|错误号: -1073741571

    ├ 测试数据 03:运行时错误...|错误号: -1073741571

    ├ 测试数据 04:运行时错误...|错误号: -1073741571

    ├ 测试数据 05:运行时错误...|错误号: -1073741571

    ├ 测试数据 06:运行时错误...|错误号: -1073741571

    ├ 测试数据 07:运行时错误...|错误号: -1073741571

    ├ 测试数据 08:运行时错误...|错误号: -1073741571

    ├ 测试数据 09:运行时错误...|错误号: -1073741571

    ├ 测试数据 10:运行时错误...|错误号: -1073741571

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

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

    const

    p:array[1..4,1..2]of longint=((-1,0),(1,0),(0,-1),(0,1));

    var

    a,f:array[0..510,0..510] of longint;

    i,j,ii,jj,t,max,n,m,k:longint;

    b:array[0..2510] of longint;

    c:array[0..2510,1..2] of longint;

    begin

    readln(n,m);

    for i:=1 to n do

    for j:=1 to m do

    begin f:=1;read(a);b[(i-1)*m+j]:=a;c[(i-1)*m+j,1]:=i;c[(i-1)*m+j,2]:=j;end;

    for i:=1 to n*m-1 do

    for j:=i+1 to n*m do

    if b[i]>b[j] then

    begin t:=b[i];b[i]:=b[j];b[j]:=t;

    t:=c;c:=c[j,1];c[j,1]:=t;

    t:=c;c:=c[j,2];c[j,2]:=t;end;

    for i:=1 to n*m do

    begin

    max:=0;

    for k:=1 to 4 do

    begin ii:=c+p[k,1];jj:=c+p[k,2];

    if (ii in[1..n])and(jj in[1..m])and(a[c,c]>a[ii,jj])and(f[ii,jj]>max)

    then max:=f[ii,jj];

    end;

    f[c,c]:=f[c,c]+max;

    end;

    max:=0;

    i:=n*m; while b[i]=b do i:=i-1;

    for j:=i to n*m do

    if f[c[j,1],c[j,2]]>max then max:=f[c[j,1],c[j,2]];

    write(max);

    end.

    为什么会这样啊。。。。。。谁能告诉我。。。谢谢了

  • 0
    @ 2009-08-06 19:29:29

    记忆化搜索

  • 0
    @ 2009-08-05 16:15:09

    编译通过...

    ├ 测试数据 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-03 17:58:25

    如对本题有疑问可以参看我的题解:http://xujieqi.blog.hexun.com/35722312_d.html

  • 0
    @ 2009-08-02 15:00:41

    .

  • 0
    @ 2009-08-02 14:20:38

    program li;

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

    var i,j,max,r,c:longint;

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

    f:array[0..1000,0..1000]of longint;

    procedure try(x,y,sum:longint);

    var i,j:longint;

    begin

    f[x,y]:=sum;

    for i:=1 to 4 do

    if (a[x+b,y+b]f[x+b,y+b]) then

    try(x+b,y+b,f[x,y]+1);

    end;

    begin

    readln(r,c);

    for i:=0 to r+1 do begin a:=maxlongint; a:=maxlongint; end;

    for i:=0 to c+1 do begin a[0,i]:=maxlongint; a[r+1,i]:=maxlongint; end;

    for i:=1 to r do

    for j:=1 to c do

    read(a);

    for i:=1 to r do

    for j:=1 to c do

    if f=0 then try(i,j,1);

    for i:=1 to r do

    for j:=1 to c do

    if f>max then max:=f;

    writeln(max);

    end.

    ............为什么要QSORT........直接DP

  • 0
    @ 2009-08-01 13:38:27

    编译通过...

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

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

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

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

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

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

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

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

    ├ 测试数据 09:运行时错误...| 错误号: 202 | 堆栈溢出错

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

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

    Unaccepted 有效得分:80 有效耗时:25ms

    快排+dp哪位大牛告诉我是为什么。。。

    var x,y:array[1..30000] of longint;

    a:array[1..30000] of longint;

    d,main:array[0..501,0..501] of longint;

    k,r,c,h,i,j,max,maxx:longint;

    procedure init;

    begin

    readln(r,c);

    for i:=1 to r do

    for j:=1 to c do begin

    k:=(i-1)*c+j;

    x[k]:=i;y[k]:=j;

    read(a[k]);

    main:=a[k];

    end;

    end;

    procedure kp(l,r:longint);

    var t,xx,i,j:longint;

    begin

    xx:=a[l];i:=l;j:=r;

    repeat

    while ((a[j]>=xx) and (j>i)) do dec(j);

    if j>i then begin

    t:=a[i];a[i]:=a[j];a[j]:=t;

    t:=x[i];x[i]:=x[j];x[j]:=t;

    t:=y[i];y[i]:=y[j];y[j]:=t;

    end;

    while ((a[i]i)) do inc(i);

    if j>i then begin

    t:=a[i];a[i]:=a[j];a[j]:=t;

    t:=x[i];x[i]:=x[j];x[j]:=t;

    t:=y[i];y[i]:=y[j];y[j]:=t;

    end;

    until i=j;

    dec(j);inc(i);

    if j>l then kp(l,j);

    if imaxx then maxx:=d[x[i],y[i]];

    end;

    end;

    begin

    init;

    kp(1,k);

    dp;

    writeln(maxx);

    end.

  • 0
    @ 2009-07-29 10:06:30

    记忆化搜索果然是王道

    程序写30行就行了

  • 0
    @ 2009-07-28 18:42:21

    编译通过...

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

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

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

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

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

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

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

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

    ├ 测试数据 09:运行时错误...| 错误号: 202 | 堆栈溢出错

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

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

    Unaccepted 有效得分:80 有效耗时:25ms

    ...

  • 0
    @ 2009-07-28 09:19:19

    爱死记忆化搜索了..........

信息

ID
1011
难度
6
分类
动态规划 点击显示
标签
递交数
10333
已通过
2937
通过率
28%
被复制
23
上传者