Cod sursa(job #1129089)

Utilizator mihaiavram96Avram Mihai mihaiavram96 Data 27 februarie 2014 20:07:00
Problema Ubuntzei Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.93 kb
#include <iostream>
#include <fstream>
#define Pinfinit 9

using namespace std;

fstream f("ubuntzei.in", ios::in);
fstream g("ubuntzei.out", ios::out);

struct muchie{int e1, e2, c;}muchia[10000],aux,sol[10000];
int i,m,n,j,a[10000][10000],k,oras[10000];
void citire()
{
    f>>n>>m>>k;
    for(i=1; i<=k; i++)
        f>>oras[i];
    for(i=1;i<=m;i++)
        f>>muchia[i].e1>>muchia[i].e2>>muchia[i].c;
    f.close();

}
void matad()
{
    for(i=1; i<=n; i++)
        for(j=1;j<=n;j++)
                a[i][j]=Pinfinit;
    for(i=1;i<=m;i++)
        a[muchia[i].e1][muchia[i].e2] = muchia[i].c;


}
void prel_20p()
{
    for(k=1;k<=n;k++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if(a[i][j] > a[i][k] + a[k][j] && i!=j && i!=k)
                    a[i][j] = a[i][k] + a[k][j];

    g<<a[1][n];
}
int main()
{
    citire();
    matad();
    prel_20p();
    return 0;
}