Pagini recente » Cod sursa (job #456096) | Cod sursa (job #1042303) | Cod sursa (job #1136210) | Cod sursa (job #446191) | Cod sursa (job #2830827)
#include <fstream>
#include "vector"
using namespace std;
ifstream f("distante.in");
ofstream g("distante.out");
int n, t, m;
vector<int> a;
int main()
{
int x,y,z,k;
bool afis;
f >> t;
for (int j=0; j < t; ++j)
{
afis=true;
f >> n >> m >> k;
a.resize(n+1);
for (int i = 1; i <= n; ++i)
f >> a[i];
if (a[k] != 0) {
afis=true;
}
for (int i = 0; i < m; ++i)
{
f >> x >> y >> z;
if (abs(a[x] - a[y]) > z) {
afis=false;
}
}
if(afis){
g<<"DA"<<'\n';
}
else
g<<"NU"<<'\n';
}
return 0;
}