Pagini recente » Cod sursa (job #2522726) | Cod sursa (job #3140734) | Cod sursa (job #149806) | Cod sursa (job #1405411) | Cod sursa (job #887115)
Cod sursa(job #887115)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("distante.in");
ofstream out("distante.out");
const int N=50001;
int n,m,s,t,d[N];
int main()
{
int ok=1;
in>>t;
for(int i=1;i<=t;i++)
{
ok=1;
int x,y,c;
in>>n>>m>>s;
for(int i=1;i<=n;i++)
in>>d[i];
if(d[s]) ok=0;
for(int i=1;i<=m && ok;i++)
{
in>>x>>y>>c;
if(d[x]+c<d[y])
ok=0;
if(d[x]+c==d[y])
ok++;
}
if(ok>1) out<<"DA"<<'\n';
else out<<"NU"<<'\n';
}
return 0;
}