Religious people

https://ide.codingblocks.com/s/466564 now whats wrong?

hello @samardeep

again same issue.

consider->
1
3 1 2 2
1 2

I am saying in 3 1 2 2 you have 1 edge ,and for one edge atleast two vertices whould be there, so in my code i will get x and y as vertices. then whats the problem?

and for 1 3 1 2 2 1 2 case output should be 4 and my code is giving the same

total 3 vertices are there.

1,2 ,3.

there is an edge between 1–2 and vertices 3 is alone.

so u need to build temple at 1 and build the road between 1–2 ,cost will be 2+2.

and because 3 is isolated ,u need to build temple at 3 as well cost will be 2.

total cost=4+2=6

then how will i store left over vertices in adjacency list?

if v is the total number of vertices and n is the number of entries in map
then v-n is the left over vertices.

so u need to add a*(v-n) in ur answer.

refer this for clarity->

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.