#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; long long int INF = 3e18; double Pi = 3.1415926535897932384626; vector G[500005]; vector

tree[500010]; priority_queue pql; priority_queue

pqp; //big priority queue priority_queue ,greater > pqls; priority_queue ,greater

> pqps1,pqps2; //small priority queue //top pop int dx[8]={1,0,-1,0,1,1,-1,-1}; int dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "DRUL"; //ll bit[500005]; //↓,→,↑,← #define p(x) cout<> n >> m; for(i=0;i> a >> b >> c; tree[a].pb(P(b,c)); tree[b].pb(P(a,c)); tree[a+100000].pb(P(b+100000,c)); tree[b+100000].pb(P(a+100000,c)); tree[a].pb(P(b+100000,0ll)); tree[b].pb(P(a+100000,0ll)); } for(i=1;i<=n;i++){ cost1[i] = INF; cost2[i] = INF; } for(i=100001;i<=n+100000;i++){ cost1[i] = INF; cost2[i] = INF; } pqps1.push(P(0,1)); cost1[1] = 0; while(!pqps1.empty()){ P p = pqps1.top(); pqps1.pop(); ll v = p.second; if(cost1[v] < p.first)continue; for(i=0;i cost1[v] + x.second){ cost1[x.first] = cost1[v] + x.second; pqps1.push(P(cost1[x.first],x.first)); } } } cost2[100001] = 0; pqps2.push(P(0,100001)); while(!pqps2.empty()){ P p = pqps2.top(); pqps2.pop(); ll v = p.second; if(cost2[v] < p.first)continue; for(i=0;i cost2[v] + x.second){ cost2[x.first] = cost2[v] + x.second; pqps2.push(P(cost2[x.first],x.first)); } } } for(i=1;i<=n;i++){ if(i == 1){ p(0); }else{ p(cost1[i + 100000] + cost2[i + 100000]); } } //p(ans); return 0; }