typedef struct { bool operator ()(const intpair& a, intpair& b)const { return a.second > b.second; } }cmp; int dis[maxn]; bool vis[maxn]; priority_queue<intpair, vector<intpair>, cmp>q; void dijstkra(int x) { mem(dis, 0x3f); dis[x] = 0; q.push(intpair(x, dis[x])); while (!q.empty) { intpair t = q.top(); q.pop(); if (vis[t.first]) continue; vis[t.first] = true; for (int i = head[x]; i != -1; i = e[i].nxt) { int u = e[i].u; int w = e[i].w; if (!vis[u] && dis[u] > t.first + w) { dis[u] = t.first + w; q.push(intpair(u, dis[u])); } } } }