← CSES Better

Highway Bypass

INOI · 2014 · Indian National Olympiad in Informatics · INOI1401

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 · dynamic-programming · path-counting

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

direction run grid

Add direction and run length to each intersection

A move continues straight only until the run limit; obstacles remove intersections from the route.

Problem grid; highlighted cells show the illustrated path
intersection->run d
^v
run 1<-intersection
  1. 1

    Track direction

    Start at the north-west intersection with no previous direction.
  2. 2

    Limit straight runs

    Transition right/down while resetting or increasing the consecutive-run count.
  3. 3

    Sum valid paths

    Sum route counts reaching the south-east exit across all valid states.
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.