Cod sursa(job #872001)

Utilizator suzanicaSuzanica Mihu suzanica Data 5 februarie 2013 17:39:14
Problema Distante Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>
using namespace std;
ifstream f("distante.in");
ofstream g("distante.out");
int d[50001];
int main()
{
    int t,i,j,n,m,s,x,y,c,ok;
    f>>t;
    for(i=0;i<t;i++)
    {
        ok=1;
        f>>n>>m>>s;
        for(j=1;j<=n;j++)
        {
            f>>d[j];
           // if(j==s && d[j]!=0)
            //ok=0;
        }
        for(j=1;j<=m;j++)
        {
            f>>x>>y>>c;
            if(d[x]+c<d[y] || d[y]+c<d[x])
            ok=0;
        }

        if(!ok)
         g<<"NU"<<'\n';
        else g<<"DA"<<'\n';
    }
}