← All problemsSign in

Another Shortest Paths Problem

CodeChefRating 2168Open on judge ↗

You are in a grid of dimensions $N \times M$. You are allowed to perform two types of operations: - Go down, left, up, or right each for a cost of $X$. Formally, if you are at the cell $(i,j)$ of the grid, you can go to either of the cells $(i + 1, j)$, $(i, j - 1)$, $(i - 1, j)$ or $(i, j + 1)$ at a cost of $X$. - Go diagonally down-left, down-right, up-left, up-right, for a cost of $Y$. Formall

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