This question is about getting all the number of nodes in a connected component then multiplying all the sizes of the components with each other right?

this is https://ide.codingblocks.com/s/467279, where i have implemented the same on submitting gives correct for just the sample test case then WA for others is there a logical error?

hello @shibangi

if sz is the size of component. then contribution corresponding to this componen will be

sz * (n-sz) where n is total number of vertices.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.