/* validation */ #include #include "testlib.h" #include using ll = long long; const ll n_min = 2, n_max = 300'000; int main() { registerValidation(); const ll n = inf.readLong(n_min, n_max); inf.readEoln(); atcoder::dsu uf(n); for(int i = 0; i < n-1; i++) { const ll u = inf.readLong(1, n) - 1; inf.readSpace(); const ll v = inf.readLong(1, n) - 1; inf.readEoln(); ensure(!uf.same(u, v)); uf.merge(u, v); } ensure(uf.size(0) == n); inf.readEof(); return 0; }