Pagini recente » Cod sursa (job #1759385) | Cod sursa (job #518916) | Cod sursa (job #2780872) | Cod sursa (job #1202428) | Cod sursa (job #735994)
Cod sursa(job #735994)
Program distante2;
var sol:array [1..50001] of longint;
i,j,n,m,t,a,b,c,s:longint;
b1,b2:array [1..1 shl 15] of char;
ok:boolean;
fi,fo:text;
begin
assign(fi,'distante.in');
assign(fo,'distante.out');
reset(fi); rewrite(fo);
settextbuf(fi,b1); settextbuf(fo,b2);
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[j]); 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.