刘汝佳 Dijkstra 队列优化


const int inf=999999999;
struct Edge{
    int from,to,dist;
    Edge(int u,int v,int d):from(u),to(v),dist(d){}
};
struct Dijkstra{
    int n,m;
    vector edges;
    vector G[maxn];
    bool done[maxn];   //永久标记
    int d[maxn];    //s到各点距离
    int p[maxn];
    void init(n){
        this->n=n;
        for(int i=0;irhs.d;
        }
    };
    void dijkstra(int s){
        priority_queue Q;
        for(int i=0;id[u]+e.dist){
                    d[e.to]=d[u]+e.dist;
                    p[e.to]=G[u][i];
                    Q.push((HeapNode){d[e.to],e.to});
                }
            }
        }
    }
};

你可能感兴趣的:(最短路)