Cod sursa(job #2830827)

Utilizator HatersMcCristian Ioan HatersMc Data 10 ianuarie 2022 12:03:12
Problema Distante Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#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;
}