Pagini recente » Cod sursa (job #643355) | Cod sursa (job #2641893) | Cod sursa (job #2123023) | Cod sursa (job #3274656) | Cod sursa (job #1631963)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream f("ubuntuzei.in");
ofstream w("ubuntuzei.out");
int n, m, k, kt[15], nt[2000][2000], l=0;
void beolvas() {
int x, y, r;
f>>n>>m>>k;
for (int i=0;i<k;i++) f>>kt[i];
for (int i=0;i<n;i++) for (int j=0;j<n;j++) nt[i][j]=0;
for (int i=0;i<m;i++) {
f>>x>>y>>r;
nt[x-1][y-1]=r;
nt[y-1][x-1]=r;
}
}
struct nemtommi {
int hossz, index;
};
void csekkol() {
if (k==0) {
queue <int> vsor;
vsor.push(n);
int h=100000, hi, hij;
while (hij!=1) {
hi=vsor.front();
vsor.pop();
for (int i=0;i<n;i++) {
if (h>nt[hi-1][i] && nt[hi-1][i]!=0) {
h=nt[hi-1][i];
hij=i+1;
}
}
vsor.push(hij);
l=l+h;
}
w<<l;
}
}
int main()
{
beolvas();
csekkol();
//for (int i=0;i<n;i++) {for (int j=0;j<n;j++) cout<<nt[i][j]<<' '; cout<<"\n";}
f.close();
w.close();
}