Cod sursa(job #2227558)

Utilizator AndreiTurcasTurcas Andrei AndreiTurcas Data 1 august 2018 02:24:57
Problema Distante Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <queue>
#include <vector>
#include <cstring>
#define oo 0x3f3f3f3f
using namespace std;

ifstream f("distante.in");
ofstream g("distante.out");

int T, n, m, s;
vector<int> Dist(50001);

int main()
{
    f >> T;
    for(int i = 1; i <= T; ++i)
    {
    bool K = 1;
        f >> n >> m >> s;
        for(int j = 1; j <= n; ++j)
            f >> Dist[j];
        for(int j = 1; j <= m; ++j)
        {
            int x, y, c;
            f >> x >> y >> c;
            if(Dist[x] + c < Dist[y] || Dist[y] + c < Dist[x]) K = 0;
        }
        if(K) g << "DA\n";
        else g << "NU\n";
    }
}