Cod sursa(job #961754)

Utilizator antonioteoZait Teodor Antonio antonioteo Data 12 iunie 2013 20:04:06
Problema Distante Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <fstream>
#include <vector>
using namespace std;
const char iname[] = "distante.in";
const char oname[] = "distante.out";
ifstream fin(iname);
ofstream fout(oname);
int T, N, M, S, i, j, a, b, c, oke;
int d[50001];
struct trip{int x, y, z; trip(){}; trip(int G, int H, int I){x = G; y = H; z = I;};};
vector < trip > v;
vector < trip > :: iterator it;
int main(){
	fin >> T;
	while (T--){
		fin >> N >> M >> S;
		oke = 1;
		for (i = 1; i <= N; ++i) fin >> d[i];
		if (d[S] != 0) oke = 0;
		for (i = 1; i <= M && oke; ++i){
			fin >> a >> b >> c;
			if (d[a] + c < d[b] || d[b] + c < d[a]) oke = 0;
		}
		if (oke) fout << "DA\n";
		else
			fout << "NU\n";
	}
	return 0;
}