Pagini recente » Cod sursa (job #2217853) | Cod sursa (job #2821349) | Cod sursa (job #281290) | Cod sursa (job #2736440) | Cod sursa (job #24770)
Cod sursa(job #24770)
//amlei
type conj = array[1..51] of integer;
var f:array[1..2,1..501] of conj;
daa :array[1..501] of boolean;
n,t,u,nr1,nr2:integer;
function exista(z:conj; unde,nr:integer;var poz :integer):boolean;
var i,j:integer;
k:boolean;
begin
for i:=1 to nr do
begin
k:=true;
for j:=1 to n do
if f[unde,i,j] <> z[j] then k:=false;
if k then
begin
exista:=true;
poz:=i;
exit;
end;
end;
exista:=false;
end;
procedure sort(var z:conj);
var i,j,aux:integer;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if z[i] > z[j] then
begin
aux:=z[i];
z[i]:=z[j];
z[j]:=aux;
end;
end;
function ok:boolean;
var i,j:integer;
k:boolean;
begin
ok:=true;
for i:=1 to nr1 do
if not daa[i] then ok:=false;
end;
procedure citire;
var i,j,poz:integer;
aux:conj;
begin
assign(input,'amlei.in'); reset(input);
assign(output,'amlei.out'); rewritE(output);
while not eof do
begin
readln(n,t,u);
nr1:=0; nr2:=0;
fillchar(daa,sizeoF(daA),false);
for i:=1 to t do
begin
for j:=1 to n do
read(aux[j]);
sort(aux);
if not exista(aux,1,nr1,poz) then
begin
nr1:=nr1+1;
f[1,nr1]:=aux;
end;
end;
readln;
for i:=1 to u do
begin
for j:=1 to n do
read(aux[j]);
sort(aux);
if exista(aux,1,nr1,poz) then
daa[poz]:=true
else break;
end;
readln;
if ok then writeln('DA') else writeln('NU');
end;
closE(input); close(output);
end;
begin
citire;
end.