Cod sursa(job #1489525)
| Utilizator | Data | 21 septembrie 2015 13:50:14 | |
|---|---|---|---|
| Problema | Distante | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
using namespace std;
int main(){
bool k;
int T, N, M, s,c;
int d[50001];
int a, b, cost;
ifstream f("distante.in");
ofstream of("distante.out");
f >> T;
for (int p = 0; p < T; ++p){
f >> N >> M >> s;
k = 1;
for (int i = 1; i <=N; ++i)f >> d[i];
if (d[s] != 0)k = 0;
for (int i = 0; i < M; ++i){
f >> a >> b >> c;
if (d[a] + c < d[b]) k = 0;
}
if (!k) of << "NU" << "\n";
else of << "DA" << "\n";
}
}