Pagini recente » Cod sursa (job #48942) | Cod sursa (job #3174185) | Cod sursa (job #496647) | Cod sursa (job #1646957) | Cod sursa (job #24774)
Cod sursa(job #24774)
//amlei
type conj = array[1..51] of integer;
var f:array[1..1,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 QuickSort(var A: conj; Lo, Hi: Integer);
procedure Sort(l, r: Integer);
var
i, j, x, y: integer;
begin
i := l; j := r; x := a[(l+r) DIV 2];
repeat
while a[i] < x do i := i + 1;
while x < a[j] do j := j - 1;
if i <= j then
begin
y := a[i]; a[i] := a[j]; a[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort(l, j);
if i < r then Sort(i, r);
end;
begin
sort(lo,hi);
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]);
quicksort(aux,1,n);
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]);
quicksort(aux,1,n);
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.