Cod sursa(job #1534924)

Utilizator ionut98Bejenariu Ionut Daniel ionut98 Data 24 noiembrie 2015 08:14:03
Problema Ubuntzei Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include<fstream>
#define inf 200000000
using namespace std;
ifstream f("ubuntzei.in");
ofstream g("ubuntzei.out");
int n,m,i,j,k,v[205];
bool ok;
struct muchie
{
    int x,y,c;
}a[250005];
int d[250005];
int main()
{
    f>>n>>m;
    f>>k;
    for(i=1;i<=k;i++)
      f>>v[i];
    for(i=1;i<=m;i++)
    {
        f>>a[i].x>>a[i].y>>a[i].c;
        if(a[i].x==1)
          d[a[i].y]=a[i].c;
    }
    for(i=2;i<=n;i++)
      if(d[i]==0)
        d[i]=inf;
    do
    {
        ok=1;
        for(i=1;i<=m;i++)
          if(d[a[i].y]>d[a[i].x]+a[i].c)
          {
              ok=0;
              d[a[i].y]=d[a[i].x]+a[i].c;
          }
    }while(ok==0);
    g<<d[n];
    return 0;
}