为什么只过了五个点

编译成功

测试数据 #0: WrongAnswer, time = 0 ms, mem = 1328 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 1332 KiB, score = 0
测试数据 #2: Accepted, time = 0 ms, mem = 1328 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 1324 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 1328 KiB, score = 10
测试数据 #5: WrongAnswer, time = 0 ms, mem = 1328 KiB, score = 0
测试数据 #6: Accepted, time = 0 ms, mem = 1328 KiB, score = 10
测试数据 #7: WrongAnswer, time = 15 ms, mem = 1332 KiB, score = 0
测试数据 #8: WrongAnswer, time = 0 ms, mem = 1328 KiB, score = 0
测试数据 #9: Accepted, time = 93 ms, mem = 1328 KiB, score = 10
WrongAnswer, time = 108 ms, mem = 1332 KiB, score = 50
代码
var
a:array[1..2000] of string;
f:array[1..2000] of integer;
i,j,k,l,n,m,ans:longint;
s:string;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
for j:=i+1 to n do
if length(a[i])>length(a[j])
then
begin
s:=a[i];
a[i]:=a[j];
a[j]:=s;
end;
ans:=1;
f[n]:=1;
for i:=n-1 downto 1 do
begin
f[i]:=1;
for j:=i+1 to n do
if (pos(a[i],a[j])<>0)and(f[j]+1>f[i]) then f[i]:=1+f[j];
if f[i]>ans then ans:=f[i];
end;
write(ans);
end.

4 条评论

  • @ 2015-10-30 12:50:14

    type
    sz=array [1..2000] of string;
    var
    a:sz;
    js:array [1..2000] of integer;
    n,s,i,j,max:integer;

    procedure sort(var a:sz;l,r:integer);
    var
    i,j,x:integer;
    y:string;
    begin
    i:=l;
    j:=r;
    x:=length(a[(l+r) div 2]);
    repeat
    while length(a[i])<x do
    inc(i);
    while x<length(a[j]) do
    dec(j);
    if not(i>j) then
    begin
    y:=a[i];
    a[i]:=a[j];
    a[j]:=y;
    inc(i);
    dec(j);
    end;
    until i>j;
    if l<j then
    sort(a,l,j);
    if i<r then
    sort(a,i,r);
    end;

    begin
    readln(n);
    for i:=1 to n do
    begin
    readln(a[i]);
    js[i]:=1;
    end;
    sort(a,1,n);
    for i:=2 to n do
    for j:=1 to i-1 do
    if (pos(a[j],a[i])<>0) and (js[j]+1>js[i]) then
    js[i]:=js[j]+1;
    max:=0;
    for i:=1 to n do
    if js[i]>max then
    max:=js[i];
    writeln(max);
    end.贴上我的程序,我的和你几乎一模一样,自己做的,因此。。。。错的点都一样。求大神解答

  • @ 2015-10-30 12:49:54

    type
    sz=array [1..2000] of string;
    var
    a:sz;
    js:array [1..2000] of integer;
    n,s,i,j,max:integer;

    procedure sort(var a:sz;l,r:integer);
    var
    i,j,x:integer;
    y:string;
    begin
    i:=l;
    j:=r;
    x:=length(a[(l+r) div 2]);
    repeat
    while length(a[i])<x do
    inc(i);
    while x<length(a[j]) do
    dec(j);
    if not(i>j) then
    begin
    y:=a[i];
    a[i]:=a[j];
    a[j]:=y;
    inc(i);
    dec(j);
    end;
    until i>j;
    if l<j then
    sort(a,l,j);
    if i<r then
    sort(a,i,r);
    end;

    begin
    readln(n);
    for i:=1 to n do
    begin
    readln(a[i]);
    js[i]:=1;
    end;
    sort(a,1,n);
    for i:=2 to n do
    for j:=1 to i-1 do
    if (pos(a[j],a[i])<>0) and (js[j]+1>js[i]) then
    js[i]:=js[j]+1;
    max:=0;
    for i:=1 to n do
    if js[i]>max then
    max:=js[i];
    writeln(max);
    end.贴上我的程序,我的和你几乎一模一样,自己做的,因此。。。。错的点都一样。求大神解答

  • @ 2015-08-11 20:26:58

    人品

  • @ 2015-05-17 15:53:25

    真的,为什么????????
    是不是因为这是一个意外

  • 1

信息

ID
1028
难度
4
分类
动态规划 | LIS 点击显示
标签
(无)
递交数
6000
已通过
2434
通过率
41%
被复制
9
上传者