Mai intai trebuie sa te autentifici.
Cod sursa(job #1143023)
| Utilizator | Data | 14 martie 2014 15:52:06 | |
|---|---|---|---|
| Problema | Distante | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <iostream>
#include <fstream>
using namespace std;
#define nmax 50005
ifstream in("distante.in");
ofstream out("distante.out");
int cost[nmax],T;
int i,j,n,m,s,a,b,c;
int main(){
in >> T;
for (i=1; i<=T; i++){
in >> n >> m >> s;
for (j=1; j<=n; j++) in >> cost[j];
bool ok=true;
if (cost[s]) ok=false;
for (j=1; j<=m; j++){
in >> a >> b >> c;
if (cost[a]>cost[b]+c || cost[b]>cost[a]+c) ok=false;
}
if (!ok) out << "NU\n";
else out << "DA\n";
}
return 0;
}