← CSES Better

Island Vacation

USACO · 2024 · January · 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.

sample trace

Island Vacation: graph algorithms walkthrough

Island Vacation: use the linked editorial?s graph algorithms, trees idea on the published sample, then verify the displayed output.

Published input2 3 2 0 10 111111112 1 3 2 3 6 5 500000004 0 0 0 0 0 1 5 1 3 4 5 5 6 1 2 2 5 5 333333336 333333336 0 0 0 1 2 2 3 3 4 4 5 1 5 5 5 0 0 0 0 0 1 2 2 3 2 4 1 4 1 5 1 11 13 2 3 4 5 6 7 8 9 10 11 12 1 2 1 3 2 3 2 4 4 5 2 5 4 8 5 9 2 6 6 7 2 7 6 10 5 11modelAlgorithm 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 output0 888888896 111111112 500000004 166666668 166666668 83333334 0 83333334 777777784 222222224 0 0 0 0 0 333333336 0 666666672 133332478 200000394 577778352 999999971 399999938 933333282 355555536 800000020 18 600000029 18
  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.