(UWCOI 2020) Problem: Escape

Solution link: https://www.codechef.com/viewsolution/29918997
This solution passed all testcase except the 1st testcase of sub-task:2 and sub-task:3.
Where this code going wrong?

You’re just ignoring the fact that keys and locked nodes exist and reducing it to a normal shortest-path problem. This gives only subtask 1. Think of how to account for keys and locked nodes to solve subtasks 2 and 3.