← All problemsSign in

Matrix Permutations

CodeChefRating 3933Open on judge ↗

There is a grid with $N$ rows and $M$ columns. There are $K$ cannons (numbered $1$ through $K$) placed in $K$ cells of this grid. Each cannon can fire a ball to any cell whose Manhattan distance from the cannon does not exceed the strength of the cannon (including the cell with the cannon). Initially (at the $0$-th second), the strengths of all the cannons are $0$ and they increase by $1$ every se

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