Pagini recente » Cod sursa (job #2050752) | Cod sursa (job #113767) | Cod sursa (job #1722144) | Cod sursa (job #1124516) | Cod sursa (job #863359)
Cod sursa(job #863359)
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
ifstream f ("distante.in");
ofstream g ("distante.out");
vector<unsigned int> cost;
int n, m, t, s;
bool bun;
int main(){
int x, y, c;
f >> t;
for(int i = 1; i <= t; ++i){
bun = true;
f >> n >> m >> s;
cost.resize(n+1);
for(int i = 1; i <= n; ++i) f >> cost[i];
if(cost[s] != 0){
g << "NU\n";
return 0;
}
for(int j = 1; j <= m; ++j){
f >> x >> y >> c;
if(cost[y] > cost[x] + c) bun = false;
}
if(!bun) g << "NU\n";
else g << "DA\n";
}
f.close();
g.close();
return 0;
}