Pagini recente » Cod sursa (job #1390195) | Cod sursa (job #21410) | Cod sursa (job #2744508) | Cod sursa (job #1097413) | Cod sursa (job #1451011)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("distante.in");
ofstream fout("distante.out");
const int Inf = 0x3f3f3f3f;
int n, t, m, s;
bool b;
vector<vector<int>> G;
vector<int> c;
void Read();
int Dfs(int x);
int main()
{
fin >> t;
while (t)
{
Read();
t--;
if ( b == 1 )
fout << "DA";
else
fout << "NU";
fout << '\n';
}
fin.close();
fout.close();
return 0;
}
void Read()
{
b = 1;
fin >> n >> m >> s;
int x, y, z;
c = vector<int>(n + 1);
for ( int i = 1; i <= n; i++)
{
fin >> c[i];
}
for ( int i = 1; i <= m; i++)
{
fin >> x >> y >> z;
if ( c[y] > c[x] + z )
b = 0;
if ( c[x] > c[y] + z )
b = 0;
}
}