← All problemsSign in

The battlefield

CodeChefRating 2175Open on judge ↗

The Ministry of Defence (MoD) of Mighty Mouse Kingdom (MMK) needs to arrange defence forces in a battlefield to prevent possible attacks of Catland's army. The battlefield is a square grid of N rows and N columns. The cell in the ith row and jth column is denoted by (i,j), with 0 ≤ i, j ≤ N-1. The MoD wants to put exactly N cannons in cells of the grid. Each cannon can guard all the cells that ar

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