Pagini recente » Cod sursa (job #2025263) | Cod sursa (job #3230143) | Cod sursa (job #2428876) | Cod sursa (job #2585092) | Cod sursa (job #1075091)
#include<cstdio>
#include<vector>
using namespace std;
struct muchie {int x,y,c;} G[100005];
int t,k,m,n,s,d[50005];
void rez()
{
int x,y,c,i;
bool ok;
scanf("%d%d%d",&n,&m,&s);
for (i=1;i<=n;++i)
scanf("%d",&d[i]);
for (i=1;i<=m;++i)
{
scanf("%d%d%d",&x,&y,&c);
G[++k].x=x, G[k].y=y, G[k].c=c;
if (x!=y) G[++k].x=y, G[k].y=x, G[k].c=c;
}
for (i=1,ok=true;i<=k && ok;++i)
if (d[G[i].x]+G[i].c<d[G[i].y])
ok=false;
if (ok) printf("DA\n");
else printf("NU\n");
}
int main()
{
int i;
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
scanf("%d",&t);
for (i=0;i<t;++i)
rez();
return 0;
}