← All problemsSign in

Querying on a Grid

CodeChefRating 3049Open on judge ↗

Chef is helping out at a volunteering center for teaching. A child comes to Chef with a problem that he is not able to solve and asks Chef for his help. The problem is the following: Consider an M × N grid graph. The vertices in the grid graph are identified by its row and column number, i.e., for a vertex there are two numbers (i,j) associated with it, where 1 ≤ i ≤ M is its row, and 1 ≤ j ≤ N

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