题解

44 条题解

  • 0
    @ 2006-10-16 08:31:24

    本人觉得应该分别求最大序列再求公共序列,但不知为何错了。

  • -1
    @ 2015-12-13 11:52:10

    program p1264;
    var a:array[0..1001,0..1001] of longint;
    b:array[0..1001] of longint;
    c:array[0..1001] of longint;
    i,j,k,m,n,s,t,js,max,x:longint;
    begin
    readln(x);
    for k:=1 to x do
    begin
    fillchar(a,sizeof(a),0);
    read(m);
    for i:=1 to m do read(b[i]);
    readln;
    read(n);
    for i:=1 to n do read(c[i]);
    for i:=1 to m do
    begin
    for j:=1 to n do
    begin
    if b[i]=c[j] then a[i,j]:=a[i-1,j-1]+1
    else if a[i-1,j]>a[i,j-1] then a[i,j]:=a[i-1,j]
    else a[i,j]:=a[i,j-1];
    end;
    end;
    writeln(a[m,n]);
    end;
    end.

  • -1
    @ 2012-07-22 11:08:33

    给oimaster的神方法跪烂

  • -1
    @ 2009-07-02 19:55:40

    点我看题解

信息

ID
1264
难度
7
分类
动态规划 | LCS动态规划 | LIS 点击显示
标签
递交数
3412
已通过
626
通过率
18%
被复制
5
上传者