← All problemsSign in

Prison Escape

CodeChefRating 2364Open on judge ↗

A prison is represented as an $N\times M$ grid containing `0`'s and `1`'s, where `0` denotes a prisoner and `1` denotes a guard. In one move, a prisoner can move one step left, right, up, or down. Formally, from cell $(x, y)$, a prisoner can move to any of the four cells $(x-1, y), (x+1, y), (x, y-1), (x, y+1)$. A prisoner can escape if he reaches outside the prison: formally, if he reaches any

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start