← All problemsSign in

Graphs - Capture Regions

You are given a matrix $matrix$ of size $N\times N$ where each element of the matrix is either $O$ or $X$. An *unclaimed territory* in the matrix is defined as a set of $M$ coordinates $(X_i, Y_i)$ such that: - $M \ge 1$; - $1 \le X_i, Y_i \le N$; - $(X_i, Y_i) \neq (X_j, Y_j)$ if $(i\neq j)$, that is, no two coordinates are equal; - $matrix_{(X_i, Y_i)} = O$ for all $(1\le i \le M)$; - A coordin

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