dijkstra
朴素版
int dist[maxn], g[40][40];
bool vis[maxn];
void dijkstra(int cc) {
//cc是单源节点编号
for (int i = 1; i <= n; i++) {
dist[i] = g[i][cc];
}
dist[cc] = 0;
memset(vis, 0, sizeof(vis));
vis[cc] = 1;
for (int i = 1; i <= n; i++) {
int mark = -1, mindis = INF;
for (int j = 1; j <= n; j++) {
if (!vis[j] && dist[j] < mindis) {
mindis = dist[j];
mark = j;
}
}
vis[mark] = 1;
for (int j = 1; j <= n; j++) {
if (!vis[j]) {
dist[j] = min(dist[j], dist[mark] + g[mark][j]);
}
}
}
}