#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} template ostream &operator<<(ostream &os,const pair&p){ os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector &a){ for(auto &i:a)is>>i; return is; } #define reps(i,a,n) for(int i=(a);i<(n);i++) #define rep(i,n) reps(i,0,n) #define all(x) x.begin(),x.end() ll myceil(ll a,ll b){return (a+b-1)/b;} const ll INF=1e18; int main(){ int n,m; cin>>n>>m; vector>to(n); rep(i,m){ int a,b,c; cin>>a>>b>>c; a--,b--; to[a].push_back({b,c}); to[b].push_back({a,c}); } vectordst(n*2,INF); dst[0]=0; minque

que; que.push({0,0}); while(!que.empty()){ ll d=que.top().first; int x=que.top().second; que.pop(); if(dst[x]!=d)continue; if(x