Pagini recente » Cod sursa (job #263769) | Cod sursa (job #2904241) | Cod sursa (job #938239) | Cod sursa (job #1187736) | Cod sursa (job #846721)
Cod sursa(job #846721)
#include <vector>
#include <cstring>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream in("distante.in");
ofstream out("distante.out");
#define ushort int
const int maxn = 50005;
int found[maxn];
int main()
{
int t,n,m,s,i;
int k;
int a,b,c;
bool ok;
in >> t;
for( k = 1; k <= t; ++ k)
{
in >> n >> m >> s;
memset(found,0,sizeof(found));
for(i = 1 ; i <= n ; ++ i)
{
in >> found [ i ];
}
ok = 1;
if(found[s] != 0)
{
ok = 0;
continue ;
}
for(i = 1 ; i <= m ; ++ i )
{
in >> a >> b >> c;
if(found[a] + c < found[b] || found[b] + c < found[a])
ok = 0;
}
if(ok)
out << "DA\n";
else
out << "NU\n";
}
return 0;
}