#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int mod = 1e9 + 7; const ll infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; #define rep(i,n) for (int i=0; i < (n); i++) typedef double D; // 座標値の型。doubleかlong doubleを想定 typedef complex P; // Point typedef pair L; // Line typedef vector

VP; typedef pair PII; typedef pair Plii; const D EPS = 1e-9; // 許容誤差。問題によって変える #define X real() #define Y imag() #define LE(n,m) ((n) < (m) + EPS) #define GE(n,m) ((n) + EPS > (m)) #define EQ(n,m) (abs((n)-(m)) < EPS) #define mkp(x,y) make_pair(x,y) D dot(P a, P b) { return (conj(a)*b).X; } struct E{ int t; ll w; E(int to,ll weight){ t=to; w=weight; } }; vector>G; ll dp[100010][2]; int main(){ cout << fixed << setprecision(10); int N,M; cin >> N >> M; rep(i,N)G.push_back(vector()); rep(i,M){ int a,b;ll c; cin >> a >> b >> c; a--;b--; G[a].push_back(E(b,c)); G[b].push_back(E(a,c)); } rep(i,100010)rep(j,2)dp[i][j]=infll; dp[0][0]=dp[0][1]=0; priority_queueQ; Q.push(mkp(0,mkp(0,0))); while(!Q.empty()){ auto pl=Q.top(); Q.pop(); int v=pl.second.first; int f=pl.second.second; ll W=-pl.first; if(dp[v][f]W+e.w){ dp[e.t][f]=W+e.w; Q.push(mkp(-(W+e.w),mkp(e.t,f))); } //use ticket if(f==false){ if(dp[e.t][1]>W){ dp[e.t][1]=W; Q.push(mkp(-W,mkp(e.t,1))); } } } } for(int i=0;i