void dj(int p,int *d,bool *s,pq q){ for (int i=1;i<=n;i++) d[i]=inf; d[p]=0; q.push(make_pair(0,p)); // wu s[1]!! for (int z=1;z<=n;z++){ /*pii tmp=q.top();q.pop();//pop! while (!q.empty() && s[tmp.se]){ tmp=q.top();q.pop(); } if (s[tmp.se])//not q.empty()!!!!!!!!!!!!!!!!!!!!!!! abnormal stop!*/ if (q.empty()) break;//!!!!!!!!!!!!!! pii tmp=q.top();q.pop(); while (!q.empty() && s[tmp.se]){//!!!!!!! tmp=q.top();q.pop(); } int x=tmp.se; if (s[x]) break; s[x]=true; for (int i=hd[x];i;i=e[i].ne){ int y=e[i].v;//y not j! if (!s[y] && d[x]+e[i].w<d[y]){//!s! d[y]=d[x]+e[i].w; q.push(make_pair(d[y],y)); } } } }
void dj(int p,int * d,int * s,pq q){ for(int i = 1;i<=n;++i) d[i] = INF; d[p] = 0;q.push(MP(0,p)); for(int z = 1;z<=n;++z){ if(q.empty()) break; pii tmp = q.top();q.pop(); while(!q.empty() && s[tmp.Y]) tmp = q.top(),q.pop(); int x = tmp.Y; if(s[x]) break; s[x] = 1; for(int i = hd[x];i;i=e[i].ne){ int y = e[i].v; if(!s[y] && d[y] > d[x]+e[i].w)d[y] = d[x]+e[i].w,q.push(MP(d[y],y)); } } }