Pagini recente » Monitorul de evaluare | Cod sursa (job #2051946) | Statistici Anime Enjoyer (Fan_Club) | Cod sursa (job #992606) | Cod sursa (job #209640)
Cod sursa(job #209640)
program pascal;
var bun,ok:boolean;
i,j,k,p,l,nr,r,t,n:longint;
a,b:array[1..2000000] of char;
z:array[1..2000000,1..20000] of 0..1;
s:array[1..2000000] of longint;
f,g:text; c:char;
begin
assign(f,'strmatch.in'); reset(f);
assign(g,'strmatch.out'); rewrite(g);
i:=0;
j:=0;
bun:=true;
repeat
begin
read(f,c);
if (ord(c)>47) and (ord(c)<123) then
begin
i:=i+1;
a[i]:=c;
end
else
begin
readln(f);
k:=1;
while not eof(f) do
begin
read(f,c);
j:=j+1;
b[j]:=c;
for k:=1 to i do
begin
if b[j]=a[k] then z[k,j]:=1
else z[k,j]:=0;
end;
end;
bun:=false;
end;
end;
until not bun;
l:=0; nr:=0;
for p:=1 to i do
for k:=1 to j do
begin
if z[p,k]=1 then
begin
r:=p+1;
t:=k+1;
ok:=true;
for n:=i-1 downto 1 do
if (z[r,t]<>1) or (r>i) or (t>j) then
begin
ok:=false;
break;
end
else
begin
z[r,t]:=0;
r:=r+1;
t:=t+1;
end;
if ok then
begin
l:=l+1;
s[l]:=k-1;
nr:=nr+1;
end;
end;
end;
writeln(g,nr);
if nr>1000 then
for i:=1 to 1000 do write(g,s[i],' ')
else for i:=1 to l do write(g,s[i],' ');
close(f);
close(g);
end.