Cod sursa(job #1010422)
| Utilizator | Data | 14 octombrie 2013 20:53:28 | |
|---|---|---|---|
| Problema | Distante | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <cstdio>
#define N 100002
using namespace std;
int a[N/2], b[N];
int main()
{
freopen("distante.in", "r", stdin);
freopen("distante.out", "w", stdout);
int n, m, s, t, i, x, y, c, ok;
scanf("%d", &t);
while(t--)
{
scanf("%d%d%d", &n, &m, &s);
for(i=1;i<=n;i++)
{
scanf("%d", &a[i]);
}
ok=1;
for(i=1;i<=m;i++)
{
scanf("%d%d%d", &x, &y, &c);
if(a[x]+c<a[y]||a[y]+c<a[x])
{
ok=0;
break;
}
}
printf("%s\n", ((ok&&!a[s])?"DA":"NU"));
}
}
