← CSES Better

Reachable Pairs

USACO · 2025 · January · gold-2

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 · simulation

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

sample trace

Reachable Pairs: graph algorithms walkthrough

Reachable Pairs: use the linked editorial?s graph algorithms, simulation idea on the published sample, then verify the displayed output.

Published input3 2 111 1 2 1 3 3 2 000 1 2 1 3 7 8 1101101 6 2 1 2 2 3 6 3 1 3 1 7 4 5 2 7modelAlgorithm ideaRepresent the task?s objects and connections as a graph, then use the editorial?s traversal or path method to obtain the requested property.task resultExpected output3 1 0 3 0 0 11 7 4 2 1 1 0
  1. 1

    Model

    Make one vertex per task object and add an edge for each permitted relationship.
  2. 2

    Process

    Traverse or relax the graph according to the task?s path or reachability rule.
  3. 3

    Read

    Use the reached set or path result to produce the requested output.
  4. 4

    Verify the sample

    Use the published sample output to check the result of this idea on the displayed input.
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.