← All problemsSign in

F - Flip on Cycle

Consider a grid graph with $N \cdot M$ nodes. Let's represent each node by a pair of numbers $(i, j)$ - the row number $i$ and the column number $j$. Two nodes $(i_1, j_1)$ and $(i_2, j_2)$ are said to be adjacent if and only if they share an edge, formally $|i_2 - i_1| + |j_2 - j_1| = 1$. You have an $N\times M$ matrix $A$, where each $A_{i, j}$ is a binary number, i.e, $0$ or $1$. You would l

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