1 #define _CRT_SECURE_NO_WARNINGS
2 /*
3 7 10
4 0 1 5
5 0 2 2
6 1 2 4
7 1 3 2
8 2 3 6
9 2 4 10
10 3 5 1
11 4 5 3
12 4 6 5
13 5 6 9
14 6
15 */
16 #include <iostream>
17 #include <vector>
18 #include <algorithm>
19 #include <cstdio>
20 using namespace std;
21
22 const int maxn = 1010 + 20;
23 const int INF = 99999999;
24 int cost[maxn][maxn]; //表示边e=(u,v)的权值 (不存在这条边时设为INF)
25 int d[maxn]; //顶点出发的最短距离
26 bool used[maxn]; //已经使用过的图
27 int V, E;
28 void init();
29 void dijkstra(int s);
30 void input();
31
32 void init()
33 {
34 for (int i = 0; i < V; i++) {
35 for (int j = 0; j &l