Cod sursa(job #837343)

Utilizator stoicatheoFlirk Navok stoicatheo Data 17 decembrie 2012 21:30:17
Problema Distante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<cstdio>
#include<cstring>
using namespace std;
int n,i,j,k,a,b,m,rez,T,s[50005],x;
bool ok=true;
 
int main()
{
    freopen("distante.in","r",stdin);
    freopen("distante.out","w",stdout);
    scanf("%d ",&T);
    for (i=1;i<=T;i++)
    {
        ok=true;
        memset(s,0,sizeof(s));
        scanf("%d %d %d",&n,&m,&x);
        for (j=1;j<=n;j++) scanf("%d",&s[j]);
        if (s[x]!=0) ok=false;
        for (j=1;j<=m;j++) 
            {
                scanf("%d %d %d",&a,&b,&k);
                if (s[a]+k<s[b]) ok=false;
            }       
        if (ok) printf("DA\n");else printf("NU\n");
    }
    return 0;
}