int dis[100000];bool v[100000]; void dijkstra(int s) { memset(dis,0x7f,sizeof(dis));ma(v); priority_queue<pair<int,int> >q; dis[s]=0; q.push(make_pair(0,s)); while(q.size()) { int x=q.top().second;q.pop(); if(v[x])continue; v[x]=1; for(int i=f(x);i;i=n(i)) if(dis[v(i)]>dis[x]+w(i)) dis[v(i)]=dis[x]+w(i), q.push(make_pair(-dis[v(i)],v(i))); } }
一直不会打……今天补上