void dijkstra(int s) { dist.assign(n+1, INF); dist[s] = 0LL; par.assign(n+1, -1); priority_queue <pp, vector <pp>, greater <pp> > PQ; PQ.push(pp(dist[s], s)); while (!PQ.empty()) { pp front = PQ.top(); PQ.pop(); long long int d = front.first; int u = front.second; if (d > dist[u]) continue; for (int j = 0; j < (int)AdjList[u].size(); j++) { pp v = AdjList[u][j]; if (dist[v.first] > dist[u] + v.second) { dist[v.first] = dist[u] + v.second; par[v.first] = u; PQ.push(pp(dist[v.first], v.first)); } } } }