Cod sursa(job #253927)

Utilizator DiaconuDiaconu Loredana Diaconu Data 6 februarie 2009 13:40:14
Problema Episoade Scor 10
Compilator fpc Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 1 Marime 1.15 kb
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.