← All problemsSign in

X-Ray Grid

CodeChefRating 2939Open on judge ↗

You are given a **binary** grid of size $N \times M$, representing an X-Ray scan at an airport. A *bag* is defined as a rectangular subgrid completely bordered by ones ($1$s). The **weight** of such a *bag* is defined as the count of ones **strictly inside** the border. Formally, given an $N\times M$ binary grid $G$, let $S$ denote a subgrid with **top-left** cell $(R_1,C_1)$ and **bottom-rig

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