Pagini recente » Cod sursa (job #87908) | Cod sursa (job #960134) | Cod sursa (job #1625020) | Cod sursa (job #1555664) | Cod sursa (job #1018786)
#include <iostream>
#include <cstdio>
#define Nmax 50001
using namespace std;
int nrt,m,i,nod,j,n;
short int c,cost[Nmax];
bool bolund;
int main()
{
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
scanf("%d",&nrt);
for(i=1;i<=nrt;++i)
{
scanf("%d %d %d",&n,&m,&nod);
for(j=1;j<=n;++j)
scanf("%d",&cost[j]);
bolund=false;
for(j=1;j<=m;++j)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if (cost[a]+c<cost[b]) bolund=true;
if (cost[b]+c<cost[a]) bolund=true;
}
if (cost[nod]) bolund=true;
if (bolund) printf("nu\n");
else printf("da\n");
}
return 0;
}