#include using namespace std; #define INF 1000000000000000000 using ll=long long; using Graph=vector>>; int main(){ int N,M; cin>>N>>M; Graph G(N); for(int i=0;i>a>>b>>c; a--; b--; G[a].push_back(make_pair(b,c)); G[b].push_back(make_pair(a,c)); } vector dist1(N,INF),dist2(N,INF); dist1[0]=0; priority_queue,vector>,greater>> pq1,pq2; pq1.push(make_pair(dist1[0],0)); while(!pq1.empty()){ int v=pq1.top().second; pq1.pop(); for(auto p:G[v]){ int nv=p.first; ll d=p.second; if(dist1[v]+dmin(dist1[v],dist2[v]+d)){ dist2[nv]=min(dist1[v],dist2[v]+d); pq2.push(make_pair(dist2[nv],nv)); } } } for(int i=0;i