#include #include #include #include #include using namespace std; #define INF 1000000000 typedef pair P; typedef pair T; typedef struct edge { int to; long long int cost; } edge; int main() { int n, m; int a, b, c; cin >> n >> m; vector graph[n]; long long int ans[2][100010]; for(int i=0;i<100010;i++) { ans[0][i] = INF; ans[1][i] = INF; } ans[0][0] = 0; ans[1][0] = 0; edge e; for(int i=0;i> a >> b >> c; e.to = b-1; e.cost = c; graph[a-1].push_back(e); e.to = a-1; e.cost = c; graph[b-1].push_back(e); } priority_queue < T, vector, greater > que; que.push(T(0, P(1, 0))); while(!que.empty()) { T q = que.top(); que.pop(); long long cost = q.first; int point = q.second.second; int ticket = q.second.first; if(cost > ans[ticket][point]) continue; for(int i=0;i