← All problemsSign in

Grid Beauty

CodeChefRating 2601Open on judge ↗

You are given a grid of size $N \times M$ containing all integers from $1$ to $N \times M$, each exactly once. The grid is represented as $a_{i,j}$ for $1 \le i \le N$ and $1 \le j \le M$, where $i$ denotes the row index and $j$ denotes the column index. Define the **beauty** of the grid as the maximum integer $X$ ($1 \le X \le N*M+1$) such that it is possible to sort the grid into the followin

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