vector fd(N, 0); int find(int num) { if (fd[num] == num) { return num; } else { return fd[num] = find(fd[num]); } }