#pragma GCC optimize("Ofast") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } struct UnionFind{ vector par,num; UnionFind(int n):par(n),num(n,1){ iota(par.begin(),par.end(),0); //include } int find(int v){ return (par[v]==v)?v:(par[v]=find(par[v])); } void unite(int u,int v){ u=find(u),v=find(v); if(u==v)return; if(num[u]> n; vector x(n),a(n); map mp; for(int i=0;i> x[i]; mp[x[i]] = i; } for(int i=0;i> a[i]; } UnionFind uf(n); for(int i=0;i res(n); for(int i=0;i