Cod sursa(job #18591)

Utilizator adalLica Adela adal Data 18 februarie 2007 12:43:13
Problema Amlei Scor 0
Compilator fpc Status done
Runda preONI 2007, Runda 2, Clasa a 9-a si gimnaziu Marime 0.83 kb
program amlei;
var a,b,c:array[0..505] of integer;
   f,g:text;  ok:boolean;
   i,x,y,j,u,t,n,z:longint;
begin
 assign(f,'amlei.in'); reset(f);
 assign(g,'amlei.out'); rewrite(g);
 y:=1;
 while not(eof(f)) do begin
   readln(f,n,t,u); y:=1;  ok:=false;
   for i:=1 to n*t do read(f,a[i]);
   readln(f);
   for i:=1 to n*t do read(f,b[i]);
   readln(f);
   for i:=1 to t do begin
     x:=i*n;
     for j:=x-n+1 to x do
       if a[j]<0 then c[a[j]]:=0 else c[a[j]]:=1;
     y:=1;
     for j:=1 to u*t do begin
       if b[j]<0 then if c[-b[j]]>0 then x:=0 else x:=1
                 else x:=c[b[j]];
       y:=y and x;
       if j mod n=0 then begin
         if y=1 then ok:=true;
         y:=1;
       end;
    end;
   end;
   if ok=true then writeln(g,'DA') else writeln(g,'NU');
 end;
 close(f); close(g);
end.