Cod sursa(job #1052232)
| Utilizator | Data | 10 decembrie 2013 22:34:36 | |
|---|---|---|---|
| Problema | Distante | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.77 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("distante.in");
ofstream out("distante.out");
int T, N, M, S, cost[50010];
int main()
{
int x, y, c, i, j, ok;
in >> T;
for(i = 1; i <= T; i++){
in >> N >> M >> S;
for(j = 1 ; j <= N; j++){
in >> cost[j];
}
ok = 1;
for(j = 1; j <= M; j++){
in >> x >> y >> c;
if(cost[x] + c < cost[y]){
ok = 0;
}
if(cost[y] + c < cost[x]){
ok = 0;
}
}
if(cost[S]){
ok = 0;
}
if(ok == 0){
out << "NU\n";
}else{
out << "DA\n";
}
}
return 0;
}
