Cod sursa(job #1098973)

Utilizator WictorTTimoftii Victor WictorT Data 5 februarie 2014 13:15:34
Problema Potrivirea sirurilor Scor 14
Compilator fpc Status done
Runda Arhiva educationala Marime 0.61 kb
 Program Str ; 
  var a,b:string ; f:text ; i,j:longint ; 
   c:array[1..2000001] of 1..2000001 ;
 function G:boolean ;
   var l:longint ; label 1 ; 
  begin G:=false ; 
   for l:=2 to length(a) do if a[l]<>b[i+l-1] then goto 1 ; 
    g:=true ; 1 : 
   end ; 
   
 begin j:=0 ; 
   assign(f,'strmatch.in') ; reset(f) ; readln(f,a) ; readln(f,b) ; close(f) ;
   assign(f,'strmatch.out') ; rewrite(f) ; 
  for i:=1 to length(b)-length(a)+1 do if a[1]=b[i] then if G then begin inc(j) ; 
   c[j]:=i-1 ; end ;  if j>1000 then j:=1000 ;  writeln(f,j) ;
  for i:=1 to j do write(f,c[i],' ') ;   close(f) ;
   end .