44 条题解
-
0ayyz_ljq LV 3 @ 2006-10-16 08:31:24
本人觉得应该分别求最大序列再求公共序列,但不知为何错了。
-
-12015-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. -
-12012-07-22 11:08:33@
给oimaster的神方法跪烂
-
-12009-07-02 19:55:40@
点我看题解