您的位置:首页 > 其它

poj2752 Seek the Name, Seek the Fame 2012-1-11

2016-03-02 20:46 225 查看
http://162.105.81.212/JudgeOnline/problem?id=2752

Program Stone;
var i,j,k,n:longint;
b,a:array[1..400000]of longint;
s:ansistring;
Begin
assign(input,'input.in');reset(input);
while not(eof) do
begin
readln(s);
j:=0;b[1]:=0;
for i:=2 to length(s) do
begin
while (j>0)and(s[i]<>s[j+1]) do j:=b[j];
if s[i]=s[j+1] then inc(j);
b[i]:=j;
end;
i:=length(S);
k:=0;
while i<>0 do
begin
inc(k);
a[k]:=i;
i:=b[i];
end;
for i:=k downto 1 do write(a[i],' ');
writeln;
end;
close(input);
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: