[Cpp] // calculate the maximum rank for the sum of difference sets // if a bunch of students are indirectly or directly friends with each other, the union with the largest number of students is the maximum rank [cpp] // No know why G ++ times out but C ++ has passed # include <iostream> using namespace std; int Father [10000001]; int Rank [10000001]; int T; int Max; void Make_Set (int x) {Father [x] = x; Rank [x] = 1 ;} int Find (int x) {while (x! = Father [x]) {x = Father [x];} return x;} void Union (int x, int y) {x = Find (x ); y = Find (y); if (x = y) return; if (Rank [x]> Rank [y]) {Father [y] = x; rank [x] + = Rank [y]; if (Max <Rank [x]) Max = Rank [x];} else {Father [x] = y; rank [y] + = Rank [x]; if (Max <Rank [y]) Max = Rank [y] ;}} int main () {while (cin> T) {int x, y; Max = 1; for (long I = 0; I <= 10000000; I ++) {Make_Set (I) ;}for (int I = 1; I <= T; I ++) {cin >>x> y; Union (x, y );} cout <Max <endl;} return 0 ;}