for (int i=0;i<m;i++) { int u,v,w;cin>>u>>v>>w; cur[u].push_back({u,v,w}); }
pq.push({k,dist[k]});
while (!pq.empty()) { Node node=pq.top(); // 每次取长度最短的路尝试加入最短路 pq.pop(); int u=node.v; if (inS[u]) continue; // 此点已在最短路中,需跳过 inS[u]=1; // 不在就加入 for (Edge e:cur[u]) { int v=e.v; int w=e.w; if (dist[v]>dist[u]+w) { dist[v]=dist[u]+w; pq.push({v,dist[v]}); } } }
for (int i=0;i<dist.size();i++) { if (dist[i]==INF) cout<<"dist["<<i<<"]= INF"<<endl; else cout<<"dist["<<i<<"]= "<<dist[i]<<endl; } return0; }