Pagini recente » Cod sursa (job #1596304) | Cod sursa (job #1192763) | Cod sursa (job #91913) | Cod sursa (job #1231281) | Cod sursa (job #2830193)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("distante.in");
ofstream fout ("distante.out");
int t, n , m, nod, a[50005];
int main()
{
fin >> t;
while (t--)
{
int v = 1;
fin >> n >> m >> nod;
for (int i = 1; i <= n; i++)
fin >> a[i];
if (a[nod] != 0)
v = 0;
for (int i = 1; i <= m; i++)
{
int x , y, c;
fin >> x >> y >> c;
if (a[x] < a[y] && a[x] + c < a[y])
v = 0;
else if (a[x] >= a[y] && a[y] + c > a[x])
v = 0;
}
if (v)
fout << "DA\n";
else fout << "NU\n";
}
return 0;
}