Cod sursa(job #253861)

Utilizator lianaliana tucar liana Data 6 februarie 2009 13:02:58
Problema Episoade Scor 30
Compilator fpc Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 1 Marime 1.17 kb
program episoade;
var f, g:text;
    n, t, j, i, nr, ne, nr1:longint;
    s:string;
    a:array[0..100] of string[3];
    nu, x:array[1..100] of 0..100;
    gasit:boolean;
  begin
    assign(f,'episoade.in'); reset(f);
    assign(g,'episoade.out'); rewrite(g);
    readln(f,s);
    a[0]:='#';
    ne:=1;
    for i:=1 to length(s) do
      begin
        if (s[i]='#') or (s[i]='>')then
          begin
            ne:=ne+1;
            a[nr]:=s[i];
            nu[nr]:=nr1;
            nr1:=nr;
            nr:=0;
          end
         else
           nr:=nr*10+ord(s[i])-ord('0');
      end;
    ne:=ne+1;
    nu[nr]:=nr1;
    readln(f,t,n);
    for i:=1 to t do
      begin
        gasit:=false;
        for j:=1 to n do
          begin
            read(f,x[j]);
            if not gasit then
              begin
                if a[x[j-1]]='>' then
                  begin
                    if x[j-1]<>nu[x[j]] then
                      gasit:=true;
                  end;
              end;
          end;
        if gasit then
          writeln(g,'0')
         else
           writeln(g,'1');
      end;
    close(f);
    close(g);
  end.