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
How to counter -1 cases

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
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.
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.