Code for the problem "Religious People" unable to pass 5/7 test cases

My code for the above mentioned problem is unable to pass 5/7 test cases. I am not sure what am I doing wrong. Please help: https://ide.codingblocks.com/s/462538

hello @Yash5646

we may have more than one components in the problem.

ur logic wont work for such cases.

the idea is to find all componets and in each component u can either have 1 temple and rest connected through routes,or all having temple.

compute this for all componets and then add it