← CSES Better

The Nilgiri Tahr

INOI · 2004 · Indian National Olympiad in Informatics · INOI0401

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

grid · bfs · shortest-path

The organizer’s problem statement is available at the official source link.

grid path

Visualize The Nilgiri Tahr

Reachable rocks form a grid graph; connect orthogonal neighbors only when their heights differ by at most one.

Problem grid; highlighted cells show the illustrated path
startrockrock
rockrockrock
rockrockgrass
  1. 1

    Encode the task

    Reachable rocks form a grid graph; connect orthogonal neighbors only when their heights differ by at most one.
  2. 2

    Advance the state

    Mark legal one-foot moves as edges, then trace a path from the top-left to the grass.
  3. 3

    Read the result

    Use the final marked state to identify the requested answer.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.