Pagini recente » Cod sursa (job #2863694) | Cod sursa (job #870057) | Cod sursa (job #2633902) | Cod sursa (job #199610) | Cod sursa (job #253928)
Cod sursa(job #253928)
var f,g:text;
s:array[1..1000]of char;
a:array[1..100]of string;
b:array[1..200]of integer;
l,h,i,j,q,k,n,o,r,t:longint;
begin
assign(f,'episoade.in');reset(f);
assign(g,'episoade.out');rewrite(g);
while not eoln(f) do begin
inc(i);read(f,s[i]);end;
h:=i;
q:=0;
for i:=1 to 100 do b[i]:=1;
for i:=1 to h do
if s[i]='(' then q:=1;
if q=0 then begin
k:=1;
i:=1;
while (i<=h) do begin
if s[i]='#' then inc(k)
else begin
while (s[i]<>'>')and(i<=h)and(s[i]<>'#') do begin
a[k][b[k]]:=s[i];
inc(i);inc(b[k]);end;
a[k][b[k]]:=';';inc(b[k]);
if s[i]='#' then i:=i-1;
end;
inc(i);
end;
readln(f,t,n);
for i:=1 to t do begin
for j:=1 to n*2-1 do read(f,s[j]);
o:=1;
while o<n*2 do begin
r:=0;
for l:=1 to k do if ((s[o]=a[l][1])and((s[o+1]=' ')or(s[o+1]=a[l][2])))or((s[o]='1')and(s[o+1]='0')and(s[o+2]='0')and(a[l][1]='1')and(a[l][2]='0')and(a[l][3]='0')) then r:=l;
for l:=o to o+b[r]-2 do if (s[l]<>a[r][l-o+1])and(s[l]<>' ') then r:=0;
if r=0 then o:=2*n
else o:=o+b[k]-2;
o:=o+1;
if r=0 then writeln(g,'0')
else writeln(g,'1');
end;
end;
end;
close(f);close(G);
end.