#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int N = 1e3 + 10; const int M = 1e6 + 10; const int inf = 0x3f3f3f3f; int n, m, idx, h[N], e[M], ne[M], w[M], dist[N], st, ed; bool book[N]; vector<int> lst; void add(int a, int b, int c) { e[idx] = b, w...