KINGCON help

Dear all,
i am getting WA in http://ww2.codechef.com/problems/KINGCON/ , please help me to find out the mistake.
http://ww2.codechef.com/viewsolution/2139341 - this is the link to my code.

//