Cod sursa(job #633469)

Utilizator d.andreiDiaconeasa Andrei d.andrei Data 13 noiembrie 2011 20:23:43
Problema Distante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <cstdio>
#include <cstring>

#define file_in "distante.in"
#define file_out "distante.out"

#define nmax 150100

int T,N,M,nod;
int d[nmax];
int d1[nmax];
int x[nmax];
int y[nmax];
//int c[nmax];
int a,b,c;
int i;

int main(){
	
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	scanf("%d", &T);
	while(T--){
		
		int ok=1;
		scanf("%d %d %d", &N, &M, &nod);
		for (i=1;i<=N;++i)
			 scanf("%d", &d[i]);
		     if (d[nod]!=0) ok=0;
			 for (i=1;i<=M;++i){
		 	  scanf("%d %d %d", &a, &b, &c);
			  if (d[b]>d[a]+c || d[a]>d[b]+c) ok=0;
			 }
				  
			
		if (ok)
            printf("DA\n");
		else
			printf("NU\n");
	}
	
	return 0;
	
}