Cod sursa(job #1457329)
| Utilizator | Data | 3 iulie 2015 11:00:48 | |
|---|---|---|---|
| Problema | Distante | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.71 kb |
#include <stdio.h>
using namespace std;
const int Dim = 50005;
const int INF = 0x3f3f3f3f;
int N,M,S,T,D[Dim];
int main()
{
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
scanf("%d",&T);
while(T--)
{
bool ok = true;
scanf("%d%d%d",&N,&M,&S);
for (int i = 1;i <= N;i++)
scanf("%d",&D[i]);
if (D[S])
ok = false;
while(M--)
{
int A,B,C;
scanf("%d%d%d",&A,&B,&C);
if (D[A] + C < D[B] || D[B] + C < D[A])
ok = false;
}
if (ok)
printf("DA\n"); else printf("NU\n");
}
}
