Pagini recente » Cod sursa (job #3246744) | Cod sursa (job #1272754) | Cod sursa (job #2973650) | Cod sursa (job #3147657) | Cod sursa (job #735991)
Cod sursa(job #735991)
Program distante2;
var sol:array [1..50001] of longint;
i,j,n,m,t,a,b,c,s:longint;
ok:boolean;
fi,fo:text;
begin
assign(fi,'distante.in');
assign(fo,'distante.out');
reset(fi); rewrite(fo);
readln(fi,t);
for i:=1 to t do begin
ok:=true; readln(fi,n,m,s);
for j:=1 to n do read(fi,sol[i]); if sol[s]<>0 then ok:=false; readln(fi);
for j:=1 to m do begin
readln(fi,a,b,c);
if sol[a]+c<sol[b] then ok:=false;
end;
if ok then writeln(fo,'DA') else writeln(fo,'NU');
end;
close(fo);
end.