讨论 / 求助!why...........
寒风,飞雪 2011-08-02 03:05:00
点我顶贴 收藏 删除
KMP为什么过不了????????????????

请神牛帮助!!!!!!!!!!

才80分!!!!!!!!!

program zi;

var a,b:string;

p:array[0..256] of integer;

c:array[0..600000] of longint;

i,j,sum,k:longint;

begin

readln(a);

readln(b);

for i:=2 to length(a) do

begin

while (j>0)and(a[j+1]<>a[i]) do

j:=p[j];

if a[j+1]=a[i] then inc(j);

p[i]:=j;

end;

j:=0;

for i:=1 to length(b) do

begin

if j=0 then k:=0;

if a[j+1]<>b[i] then

begin

inc(k);

c[k]:=j;

end;

while (j>0)and(a[j+1]<>b[i]) do j:=p[j];

if a[j+1]=b[i] then inc(j);

if j=length(a) then

begin

inc(sum);

j:=c[k];

dec(k);

end;

end;

writeln(sum);

readln;

readln;

end.

题目:子串清除

状态: Unaccepted

测评机: Xeond[6]

得分: 80分

提交日期: 2011-8-2 17:43:00

有效耗时: 1515毫秒

测试结果1: 通过本测试点|有效耗时172ms

测试结果2: 通过本测试点|有效耗时188ms

测试结果3: 通过本测试点|有效耗时172ms

测试结果4: 通过本测试点|有效耗时172ms

测试结果5: 通过本测试点|有效耗时296ms

测试结果6: 通过本测试点|有效耗时297ms

测试结果7: 测试结果错误.错误结果为:1920

正确结果应为:1600

测试结果8: 测试结果错误.错误结果为:1999

正确结果应为:1600

测试结果9: 通过本测试点|有效耗时172ms

测试结果10: 通过本测试点|有效耗时46ms

查看更多回复
提交回复