← CSES Better

Tree Boxes

USACO · 2019 · US Open · platinum-1

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

graph-algorithms · trees

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

interactive trace

Tree embedding and path boxes

The official interaction embeds the chain 0-1-2 at three coordinates; each query is covered by one or two rectangles containing exactly the requested path farms.

Farm 0roadFarm 1roadFarm 2
  1. 1

    Build the tree

    The sample roads form the chain 0-1-2.
  2. 2

    Place farms

    The official interaction places 0 at (1,1), 1 at (1,2), and 2 at (2,2).
  3. 3

    Cover a path

    For query (0,2), the two boxes cover farms 0 and 1, then farm 2; together they contain exactly that path.
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.