#include <bits/stdc++.h> using namespace std; struct node{ int next,to,w; }e[1000010]; int first[1000010],a[1000010],ffffff,last = INT_MAX,len,dis[1000010],n; bool vis[1000010]; void add(int x,int y,int w){ e[++len].to = y; e[len].w = w; e[len].next = first[x]; first[x] = len; } void find(int)...