Pagini recente » Cod sursa (job #1635662) | Cod sursa (job #1115318) | Cod sursa (job #3234850) | Cod sursa (job #2867371) | Cod sursa (job #2702780)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("distante.in");
ofstream fout ("distante.out");
const int N = 50005;
int T, n, m, S, dist[N];
bool gasit;
int main()
{
fin >> T;
while (T--)
{
gasit = 1;
fin >> n >> m >> S;
for (int i = 1; i <= n; i++)
fin >> dist[i];
while (m--)
{
int a, b, cost;
fin >> a >> b >> cost;
if (dist[a] <= dist[b] && dist[a] + cost < dist[b])
gasit = 0;
if (dist[b] < dist[a] && dist[b] + cost < dist[a])
gasit = 0;
}
if (dist[S] != 0)
gasit = 0;
if (gasit)
fout << "DA\n";
else
fout << "NU\n";
}
return 0;
}