Pagini recente » Cod sursa (job #668633) | Cod sursa (job #2862870) | Cod sursa (job #981902) | Cod sursa (job #1737815) | Cod sursa (job #2033956)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("distante.in");
ofstream fout("distante.out");
int t;
int d[50007];
int n, m, s;
bool rasp;
int main()
{
int i, j, x, y, z;
fin >> t;
for (i=1; i<=t; i++)
{
rasp=1;
fin >> n >> m >> s;
for (j=1; j<=n; j++)
fin >> d[j];
if (d[s]!=0) rasp=0;
for (j=1; j<=m; j++)
{
fin >> x >> y >> z;
if (d[x]+z<d[y] || d[y]+z<d[x])
rasp=0;
}
if (rasp) fout << "DA\n";
else fout << "NU\n";
}
fin.close();
fout.close();
return 0;
}