← CSES Better

Cow Hopscotch (Bronze)

USACO · 2015 · February · bronze-3

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-search · recursive-enumeration

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

sample trace

Cow Hopscotch: branch over valid jumps

From each square, recursively jump down and right to a different color. The published 4?4 sample has three valid routes from the top-left to the bottom-right.

grid

RRRRRRBRRBBRRRRR

route Count

3

routes

1,12,34,4
1,13,24,4
1,13,34,4

start

11

goal

44
  1. 1

    Start at the top-left

    The sample starts on R at row 1, column 1.
  2. 2

    Branch on color changes

    Try each later row and column whose color differs from the current square; the sample?s next squares are the three B cells that can reach the goal.
  3. 3

    Count completed routes

    Each route ends at (4,4). The three route traces in the diagram give the sample answer 3.
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.