#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2") #include #define INF 1000000001LL #define LNF 1000000000000000001LL #define MOD 1000000007LL #define MAX 502 #define long long long #define all(x) x.begin(),x.end() using namespace std; //dijkstra void dijkstra(int x, vector> &vis, vector> graph[]) { priority_queue,long>, vector,long>>, greater,long>>> pq; for(int i = 0; i> n >> m; vector> graph[n+1]; for(int i = 0; i> a >> b >> c; graph[a].push_back({b,c}); graph[b].push_back({a,c}); } vector> vis(n+1,vector(2)); dijkstra(1,vis,graph); for(int i = 1; i<=n; i++) { cout << vis[i][0]+vis[i][1] << "\n"; } return 0; }