Pagini recente » Cod sursa (job #128459) | Cod sursa (job #1952296) | Cod sursa (job #1435907) | Cod sursa (job #2612482) | Cod sursa (job #28201)
Cod sursa(job #28201)
{ Amlei infoarena Runda 2 preONI }
program sdf;
var x,y:array[1..500] of set of byte;
n,t,u,i,j,uk,tk,aux:integer;
m:set of byte;
gasit,s:boolean;
f,g:text;
begin
assign(f,'amlei.in');reset(f);
assign(g,'amlei.out');rewrite(g);
while not eof(f) do begin
readln(f,n,t,u);
tk:=0;
for i:=1 to t do begin
m:=[];
for j:=1 to n do begin
read(f,aux);
if aux<0 then aux:=n+abs(aux);
m:=m+[aux];
end;
j:=1;gasit:=false;
while not gasit and (j<=i-1) do
if m=x[j] then gasit:=true
else j:=j+1;
if not gasit then begin
tk:=tk+1;
x[tk]:=m;
end;
end;
readln(f);
uk:=0;
for i:=1 to u do begin
m:=[];
for j:=1 to n do begin
read(f,aux);
if aux<0 then aux:=n+abs(aux);
m:=m+[aux];
end;
j:=1;gasit:=false;
while not gasit and (j<=i-1) do
if m=y[j] then gasit:=true
else j:=j+1;
if not gasit then begin
uk:=uk+1;
y[uk]:=m;
end;
end;
s:=true;i:=1;
while s and (i<=tk) do begin
gasit:=false;j:=1;
while not gasit and (j<=uk) do
if y[j]=x[i] then gasit:=true
else j:=j+1;
if not gasit then s:=false
else i:=i+1;
end;
if s and (uk=tk) then writeln(g,'DA')
else writeln(g,'NU');
readln(f);
end;
close(g);
close(f);
end.