cant find the bug in kingkon

my approach is to identify the elements which will affect the unity of the kingdom if attacked
by setting a particular node visited and then call dfs on any of the rest of the nodes
if any node remains unvisited, the node which was set visited requires shield, the code works fine for given test case but i get wrong answer as result when i submit it on Codechef, thanx for ur time…
heres my code http://ideone.com/6b5590