Cod sursa(job #98855)

Utilizator zappysBerghian Alexandru zappys Data 10 noiembrie 2007 17:50:03
Problema Abc2 Scor 0
Compilator fpc Status done
Runda Happy Coding 2007 Marime 1.33 kb
var   nr,ls,a:integer;
      c:array[1..10000000]of char;
      b:array[1..50000]of string;
      f,g:text;
      i,j,li,n:longint;
      y:string;
      ok:boolean;
begin
assign(f,'abc2.in');
assign(g,'abc2.out');
reset(f);
rewrite(g);

        begin    {citire text}
        li:=1;

        while not(eoln(f))do begin
        read(f,c[li]);
        inc(li);
        end;

        end;


        begin   {citire cuvinte}
        n:=li;

        li:=1;

        while not(eof(f))do begin
        readln(f,y);
        ok:=true;

                for i:=1 to li-1 do
                if y=b[i] then begin ok:=false; break;end;
        if ok= true then begin b[li]:=y;
        inc(li);              end;
        end;

        end;
        ls:=length(y);

        begin {partea grea}
        for i:=1 to li do begin

                for j:=1 to n-ls do begin

                        if b[i][1]=c[j]then begin
                         ok:=true;
                                for a:=2 to ls do begin
                                        if b[i][a]<>c[j+a-1] then begin ok:=false; break; end;

                                end;
                         if ok=true then inc(nr);
                        end;

                end;
            end;

        end;

writeln(g,nr);
close(f);
close(g);
end.