Can someone please help me with this problem? I have looked up the editorial and found that I have the right idea and also my solution match with some others. I have used BFS to get the answer. But I can’t seem to find whats wrong

Code: https://www.codechef.com/viewsolution/13779107

Thank you in advance!