Comments

BurningKumar, Please do not spam. This is a esteemed platform, do not insult the users of codeforces

On FirestoneI need some help..., 5 years ago
0

Perform depth first search to find all the connected( By u,v are connected I assume there is a path from u to v) components and the number of vertices in each connected component.

This gives the answer i think.