Cod sursa(job #1857847)

Utilizator abccnuCamelia Zalum abccnu Data 26 ianuarie 2017 19:25:53
Problema Ubuntzei Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream f ("ubuntzei.in");
ofstream fout ("ubuntzei.out");

const int NMAX = 2000 + 5;
const int INF=100000000;
int n , m , mat[NMAX][NMAX], c, k, dp[NMAX][NMAX];


void dinam(int x)
{
    if (x > n)return;
    for (int i=1; i<=n; ++i)
    {
        if (mat[x][i]!=0)
            dp[x][i]=dp[i][x]+min(mat[i][x], dp[i][x]);
    }
}

int main()
{
    f >> n >> m;
    int i, x, y;
    f >> k;
    for (i = 1; i <= k; ++i)
        f >> c;

    for (i = 1 ; i <= m ; ++i)
    {
        f >> x >> y >> c;
        mat[x][y] = c;
        mat[y][x] = c;


    }
int j ,ki;
    for(int ki=1;ki<=n;ki++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if((mat[i][j]>mat[i][ki]+mat[ki][j]||!mat[i][j])&&mat[i][ki]&&mat[ki][j]&&i!=j)
                    mat[i][j]=mat[i][ki]+mat[ki][j];
     fout<<mat[1][n];

   /* for (i = 1; i <= n ; ++i)
        {for ( int j = 1 ; j <= n; ++j)
    {
        cout << mat[i][j] << " ";


    }
    cout << endl;
        }*/
    return 0;
}