Pagini recente » Cod sursa (job #2036421) | Cod sursa (job #297699) | Cod sursa (job #238157) | Cod sursa (job #356109) | Cod sursa (job #18222)
Cod sursa(job #18222)
Type matrix=array[1..500,1..50] of -50..50;
vektor=array[1..50] of -50..50;
Var
be,ki:text;
a:matrix;
n:byte;
t,u,i:word;
k:integer;
v1,v2:vektor;
bool,fucs:boolean;
procedure beolvas1(var n:byte;var t,u:word);
begin
readln(be,n,t,u);
end;
Procedure beolvas2(var a:matrix;var v:vektor;n,x:word);
Var i,j,z,y:word;
begin
z:=1;
y:=0;
for i:=1 to n*x do begin
read(be,k);
if y=n then begin z:=z+1;y:=0;end;
y:=y+1;
a[z,abs(k)]:=k;
end;
readln(be);
for j:=1 to n do begin
v[j]:=j;
for i:=1 to x do
if a[i,j]<0 then
v[j]:=v[j]*(-1)
end;
end;
Begin
assign(be,'amlei.in');
reset(be);
assign(ki,'amlei.out');
rewrite(ki);
while not eof(be) do begin
beolvas1(n,t,u);
beolvas2(a,v1,n,t);
beolvas2(a,v2,n,u);
i:=0;
bool:=true;
while bool and (i<=n) do begin
i:=i+1;
if v1[i]<>v2[i] then begin bool:=false;fucs:=true;end;
end;
if fucs then begin
bool:=true;
i:=0;
while bool and (i<=n) do begin
i:=i+1;
if v1[i]<>(-v2[i]) then bool:=false
end;
end;
if bool then writeln(ki,'DA')
else writeln(ki,'NU');
end;
close(be);
close(ki);
End.