Pagini recente » Cod sursa (job #729091) | Cod sursa (job #2126817) | Cod sursa (job #256451) | Cod sursa (job #581670) | Cod sursa (job #253927)
Cod sursa(job #253927)
var f,g:text;
c:char;
cod,i,j,l,nr,num,num2,b,a,w,t,n:integer;
da:boolean;
vv,tt:array[1..1000] of integer;
ok:array[1..1000] of boolean;
x:array[1..1000] of integer;
y:array[1..1000] of char;
begin
assign (f,'episoade.in');reset(f);
assign (g,'episoade.out');rewrite (g);
nr:=0;
while not eoln(f) do begin
read(f,c);
if c in ['0'..'9'] then begin
da:=true;
val(c,a,cod);
while da do begin
read (f,c);
if c in ['0'..'9'] then begin
val(c,b,cod);
a:=a*10+b;
end
else begin
inc(nr);
ok[nr]:=true;
x[nr]:=a;
inc(nr);
ok[nr]:=false;
y[nr]:=c;
da:=false;
end;
end;
end
else begin
inc(nr);
ok[nr]:=false;
y[nr]:=c;
end;
end;
fillchar(tt,sizeof(tt),0);
for i:=1 to nr do
if not ok[i] then if y[i]='>' then tt[x[i+1]]:=x[i-1];
readln (f,t,n);
for i:=1 to t do begin
da:=true;
for j:=1 to n do
read(f,vv[j]);
for j:=1 to n do
if tt[vv[j]]<>0 then if tt[vv[j]]<>vv[j-1] then da:=false;
if da then writeln (g,1)
else writeln (g,0);
end;
close(f);close(g);
end.