Pagini recente » Cod sursa (job #3031497) | Cod sursa (job #1975089) | Cod sursa (job #1553419) | Cod sursa (job #3201976) | Cod sursa (job #253774)
Cod sursa(job #253774)
var f,f2:text;
c:array[1..1000] of char;
cnr2,j,k,i,l,a2,n,t,grupuri,cnr,cod,a:integer;
grup:array[1..100] of record
nrep:integer;
ep:array[1..100] of integer;
end;
epgr:array[1..100] of integer;
mov,pot:boolean;
function IsSign(c2:char):boolean;
var rez:boolean;
begin
rez:=false;
if (c2='#') or (c2='>') then rez:=true;
IsSign:=rez;
end;
begin
assign(f,'episoade.in');
assign(f2,'episoade.out');
l:=0;
reset(f);
rewrite(f2);
while not eoln(f) do
begin
l:=l+1;
read(f,c[l]);
end;
readln(f,t,n);
for i:=1 to n do epgr[n]:=0;
grupuri:=0;
mov:=false;
cnr:=0;
for i:=1 to l do
begin
if (not IsSign(c[i])) then
begin
Val(c[i],a,cod);
cnr:=cnr*10+a;
end
else
begin
if (c[i]='>') or mov then
begin
if not mov then
begin
mov:=true;
grupuri:=grupuri+1;
grup[grupuri].nrep:=0;
end;
grup[grupuri].nrep:=grup[grupuri].nrep+1;
grup[grupuri].ep[grup[grupuri].nrep]:=cnr;
epgr[cnr]:=grupuri;
end;
if c[i]='#' then mov:=false;
cnr:=0;
end;
end;
if mov then
begin
grup[grupuri].nrep:=grup[grupuri].nrep+1;
grup[grupuri].ep[grup[grupuri].nrep]:=cnr;
epgr[cnr]:=grupuri;
end;
for i:=1 to t do
begin
pot:=true;
for j:=1 to n do
begin
read(f,a);
if a<>0 then
begin
a2:=epgr[a];
k:=1;
while k < grup[a2].nrep do
begin
k:=k+1;j:=j+1;
read(f,a);
if epgr[a]<>a2 then
begin
k:=grup[a2].nrep;
j:=n+1;
pot:=false;
end;
end;
end;
end;
if pot then writeln(f2,1)
else writeln(f2,0);
end;
close(f);
close(f2);
end.