Cod sursa(job #2225808)
| Utilizator | Data | 28 iulie 2018 12:56:54 | |
|---|---|---|---|
| Problema | Distante | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <fstream>
using namespace std;
int cost[50005];
int main()
{
ifstream f("distante.in");
ofstream g("distante.out");
int nrteste=0;
f>>nrteste;
for(int t=1;t<=nrteste;t++)
{
int n,m,s;
f>>n>>m>>s;
for(int i=1;i<=n;i++)
f>>cost[i];
bool ok;
if(cost[s]==0)
ok=1;
else
ok=0;
for(int i=1;i<=m;i++)
{
int a,b,c;
f>>a>>b>>c;
if(cost[a]+c<cost[b] or cost[b]+c<cost[a])
ok=0;
}
if(ok==1)
g<<"DA\n";
else
g<<"NU\n";
}
return 0;
}
