Pagini recente » Cod sursa (job #2582873) | Cod sursa (job #1867458) | Cod sursa (job #1136216) | Cod sursa (job #481980) | Cod sursa (job #583296)
Cod sursa(job #583296)
#include<cstdio>
using namespace std;
int n,m,S,t,T,i,x,y,cost,dist[50001];
int main()
{
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
scanf("%d",&T);
for(t=1;t<=T;t++)
{
scanf("%d %d %d",&n,&m,&S);
for(i=1;i<=n;i++)
scanf("%d",&dist[i]);
bool ok=true;
if(dist[S])
ok=false;
for(i=1;i<=m;i++)
{
scanf("%d %d %d",&x,&y,&cost);
if(dist[x]+cost<dist[y] || dist[y]+cost<dist[x])
{
ok=false;
}
}
if(ok)
printf("DA\n");
else
printf("NU\n");
}
return 0;
}