I have counted nodes in a component say x.
cities not in that component is n-x.(n is total vertices)
so for that component no of ways is x*(n-x) /2. Done this for all the components.
Only one test case passes
Yes, this should also be correct.
I have counted nodes in a component say x.
cities not in that component is n-x.(n is total vertices)
so for that component no of ways is x*(n-x) /2. Done this for all the components.
Yes, this should also be correct.