板子:
code:(如果编译器为c++11以上的,不要这样 que.push({dx,dis[dx]}) )
struct stu{ int a,b; bool friend operator<(const stu &x,const stu &y){ return x.b>y.b; } }; void djstrea(int s){ priority_queue<stu>que; dis[s]=0; que.push({s,0}); while(que.size()){ stu xx=que.top(); que.pop(); if(mark[xx.a]==1) continue ; mark[xx.a]=1; for(int i=0;i<ve[xx.a].size();i++){ int dx=ve[xx.a][i].a; int dy=ve[xx.a][i].b; if(mark[dx]==0&&dis[dx]>dis[xx.a]+dy){ dis[dx]=dis[xx.a]+dy; que.push({dx,dis[dx]}); } } } }