Pagini recente » Cod sursa (job #2637949) | Cod sursa (job #2946046) | Cod sursa (job #1560799) | Cod sursa (job #2198072) | Cod sursa (job #863348)
Cod sursa(job #863348)
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define inf 100000000
ifstream f ("distante.in");
ofstream g ("distante.out");
struct nod_g{
int nod, cost;
};
vector< vector<nod_g> > graf;
vector<unsigned int> cost;
vector<nod_g>::iterator it;
nod_g temp;
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];
for(int j = 1; j <= m && bun; ++j){
f >> x >> y >> c;
if(cost[y] > cost[x] + c || cost[x] > cost[y] + c) bun = false;
}
if(!bun) g << "NU\n";
else g << "DA\n";
}
f.close();
g.close();
return 0;
}