Pagini recente » Cod sursa (job #2411741) | Cod sursa (job #845501) | Cod sursa (job #862066) | Cod sursa (job #930930) | Cod sursa (job #1094642)
#include<fstream>
#include<vector>
using namespace std;
int t,n,m,s,d[50001],x,y,c;
ifstream in("distante.in"); ofstream out("distante.out");
int main(){
in>>t;
for(;t;--t){
in>>n>>m>>s; bool ok=true;
for(int i=1;i<=n;++i) in>>d[i];
if(d[s]!=0){ out<<"NU\n"; continue;}
for(int i=1;i<=m;++i){
in>>x>>y>>c;
if(d[x]+c<d[y]) ok=false;
if(d[y]+c<d[x]) ok=false;
}
if(ok==true) out<<"DA\n"; else out<<"NU\n";
}
}