#include <bits/stdc++.h>
using namespace std;
struct E{
int from, to, cap;
};
struct HeapNode{
int d, u;
bool operator < (const HeapNode& rhs) const{
return d > rhs.d;
}
};
vector <E> edge;
vector <int> p[MAXN];
bool vis[MAXN];
int d[MAXN];
void read_graph (int from,int to,int cap)
{
edge.push_back((E){from, to, cap});
int m=edge.size();
p[from].push_back(m-1);
}
void dijkstra(int s)
{
priority_queue <HeapNode> Q;
for(int i=0; i<n; i++) d[i]=INF;
d[s]=0;
memset(vis, 0, sizeof(vis));
Q.push((HeapNode){0,s});
while( !Q.empty()){
HeapNode x = Q.top(); Q.pop();
int u = x.u;
if(vis[u]) continue;
vis[u] = 1;
for(int i=0; i<p[u].size(); i++){
E &e=edge[G[u][i]];
if(d[e.to] > d[u]+e.cap){
d[e.to] = d[u]+e.cap;
p[e.to] = G[u][i];
Q.push((HeapNode){d[e.to], e.to});
}
}
}
}
int main(){
return 0;
}
参考:刘汝佳紫书