How to counter -1 cases

not able to figure out how print -1 cases without traversing the visited array. also please debug the error at lino no-32.
link to my code - https://ide.codingblocks.com/s/268800

image
u are passing m as integer and then u are trying to access m[a] which is wrong u can do it for array but not integer

not able to understand what u are trying to convey
please elaborate
tell the test case or scenario u are talking about

how to handle cities which are not excluded (not connected). https://ide.codingblocks.com/s/268800

u can either count no of connectedComponents
and no of nodes in each componennt
https://ide.codingblocks.com/s/202560

or outside the queue ( while loop)
traverse for all n nodes in the graph and keep 1 vector having nodes which are visited

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.

not able to pass all the test cases . please edit my code. https://ide.codingblocks.com/s/289554

not able to pass all the test cases . please edit my code. https://ide.codingblocks.com/s/289554

Count the number of connected components and node on each connected component.
If cost of temple is less then put temple on every city else put one temple on each connected component.