DSA Learning Series

I was trying to this question, with the BFS, can anyone help, where I am doing wrong.

Question Link: https://www.codechef.com/LRNDSA08/problems/ACM14KG3
My Solution Link: https://www.codechef.com/viewsolution/39963646