#include <cstring> #include <type_traits> class UnionFind{ private: // int *nums; public: int *nums; UnionFind(int n){ nums=new int[n]; for(int i=0;i<n;i++)nums[i]=i; } ~UnionFind(){ delete [] nums; } int find(int x){ int k...