← CSES Better

Calvins Game

INOI · 2013 · Indian National Olympiad in Informatics · INOI1301

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

dynamic-programming · sequence

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

two phase path

Split the route at the phase change

The route first moves forward by one or two positions, then backward by one or two, ending at square 1.

start kincreasing-index phaseturning point -> return to 1
  1. 1

    Score forward moves

    Compute best forward scores for each reachable square.
  2. 2

    Choose the turn

    Treat each square as a possible end of the forward phase, then continue with the backward transitions.
  3. 3

    Finish backward

    Keep the maximum score that finishes at square 1.
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.