1 ///Dijkstra优先队列模板 2 struct Node 3 { 4 int x,d; 5 Node(int a,int b){x=a;d=b;} 6 bool operator < (const Node & a) const 7 { 8 return d>a.d; 9 }10 };11 vectorg[mx];12 int ds[mx];13 int n,m;14 15 void dijk()16 {17 priority_queue q;18 q.push(Node(1,0));19 while (!q.empty())20 {21 Node N=q.top();q.pop();22 for (int i=0;i y.d+N.d)26 {27 ds[y.x]=y.d+N.d;28 q.push(Node(y.x,ds[y.x]));29 }30 }31 }32 }