← CSES Better

Glass Bead Game

INOI · 2009 · Indian National Olympiad in Informatics · INOI0902

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

game-theory · dynamic-programming · minimax

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

two pile minimax

Analyze the two-pile game with alternating max and min turns

State (x,y) gives the bead counts. The turn depends on x+y parity, and each visited state contributes f(x,y) to the score.

State table
StatePlayer to moveChoice
(x,y)x+y even: youmove (x-1,y+1) or (x,y-1)
(x,y)x+y odd: opponentminimize your eventual score
position payofff(x,y)=A*x^2 + B*y^2 + C*x*y
  1. 1

    Read state and turn

    At state (x,y), it is your turn when x+y is even; otherwise it is the opponent's turn.
  2. 2

    Apply one legal move

    Move one bead from the first bowl to the second, or remove one bead from the second bowl.
  3. 3

    Evaluate the game

    Add f(x,y) at each visited state; you maximize the total and the opponent minimizes it.
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.