Pagini recente » Cod sursa (job #1503899) | Cod sursa (job #2344124) | Cod sursa (job #2891549) | Cod sursa (job #2899137) | Cod sursa (job #1090138)
#include <cstdio>
using namespace std;
int dist[50005];
int n,m,s,t;
int main()
{
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
scanf("%d",&t);
while (t--)
{
bool ok = false;
scanf("%d %d %d",&n,&m,&s);
for (int i=1;i<=n;i++)
scanf("%d",&dist[i]);
for (int i=1;i<=m;i++)
{
int a,b,d;
scanf("%d %d %d",&a,&b,&d);
if (dist[a] + d < dist[b])
ok = true;
if (dist[b] + d < dist[a])
ok = true;
if (dist[s] != 0)
ok = true;
}
if (ok)
printf("NU\n");
else
printf("DA\n");
}
return 0;
}