Cod sursa(job #209680)

Utilizator FllorynMitu Florin Danut Flloryn Data 23 septembrie 2008 22:46:54
Problema Potrivirea sirurilor Scor 14
Compilator fpc Status done
Runda Arhiva educationala Marime 1.22 kb
program pascal;
   var f,g:text;
    i,j,k,s,m,n,nr:longint;
    a,b:array[1..2000001] of char;
    c:char;
    d:array[1..2000001] of longint;
    ok,bun:boolean; 
  
 begin  
 assign(f,'strmatch.in');  
 assign(g,'strmatch.out');  
 reset(f);  
 rewrite(g);  
  n:=0;
m:=0;
bun:=true;
repeat
 begin
    read(f,c);
    if (ord(c)>47) and (ord(c)<123) then
            begin
                n:=n+1;
                a[n]:=c;
            end
             else
         begin
         readln(f);
         while not eof(f) do
            begin
                 read(f,c);
                 m:=m+1;
                 b[m]:=c;

             end;
             bun:=false;
           end;
 end;
 until not bun;

  nr:=0; s:=0;
  for i:=1 to m do
   begin
   ok:=true;
   k:=i;
   for j:=1 to n do
    if b[k]<>a[j] then
           begin
            ok:=false;
            break;
           end
            else k:=k+1;
   if ok then
        begin
          s:=s+1;
          d[s]:=i-1;
          nr:=nr+1;
        end;
   end;

 writeln(g,nr);
 if s<=1000 then
     for i:=1 to s do write(g,d[i],' ')
            else
     for i:=1 to 1000 do write(g,d[i],' ');
 close(f);  
 close(g);  
 end.