Cod sursa(job #253723)

Utilizator andreivFMI - vacaroiu andrei andreiv Data 6 februarie 2009 11:49:32
Problema Episoade Scor 50
Compilator fpc Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 1 Marime 0.77 kb
program episoade;
var f,g:text;
    x:array[1..100] of string;
    s:string;
    t,nr,n,i,j:longint;
    v:char;
    ok:boolean;

begin
assign(f,'episoade.in');
assign(g,'episoade.out');
reset(f);
rewrite(g);nr:=1;i:=0;x[1]:='';
while not eoln(f) do
begin
i:=i+1;
read(f,v);
if v='>' then ok:=false else
if (v<>'(') and (v<>')') and (v<>'#') then
x[nr]:=x[nr]+v else
if (x[nr]<>'') then
begin
nr:=nr+1;
x[nr]:='';
end;
end;
if x[nr]='' then nr:=nr-1;
readln(f);
read(f,t,n);
for i:=1 to t do
begin
readln(f);
read(f,s);
while pos(' ',s)<>0 do
delete(s,pos(' ',s),1);
ok:=true;
for j:=1 to nr do
if (x[j]<>'')and (pos(x[j],s)=0) then
begin
ok:=false;
break;
end;
if ok then writeln(g,1) else writeln(g,0);
end;

closE(f);
close(g);
end.