Cod sursa(job #537255)

Utilizator catalin.stStanciu Catalin catalin.st Data 20 februarie 2011 15:05:04
Problema Subsir Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.65 kb
var n,s:string;a:array[0..250,0..250]of byte;x,y,max,nr:byte;
procedure citire;begin assign(input,'subsir.in');reset(input); readln(n);readln(s);close(input);end;
procedure rez;
var i,j,k,l:byte;f:text;
begin
assign(f,'subsir.out');rewrite(f);
for i:=1 to length(n) do
for j:=1 to length(s) do if n[i]=s[j] then a[j,i]:=1+a[j-1,i-1];
max:=0;
for i:=1 to length(n) do
 for j:=1 to length(s) do if max<a[i,j] then begin max:=a[i,j];a[i,j]:=0;x:=i;y:=j;end;
if max<>0 then nr:=1;
for i:=1 to length(s) do for j:=1 to length(n) do
if (a[i,j]=max) then if (j>=y+max) then begin inc(nr);y:=j;end;
writeln(f,nr);
close(f);
end;
begin
citire;
rez;
end.