← CSES Better

Pair Cities to Minimize Tree Travel

ZIO · 2022 · Zonal Informatics Olympiad · P3

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

trees · matching · optimization

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

tree matching

Pair every city once along unique routes

Each pairing contributes the weighted distance on its unique tree path; find the minimum total over perfect pairings. Schematic structure only; vertices and edges represent the task relation, not an official sample. Schematic graph only; labels and edges show the task relation, not an official sample.

roadroadroadcity Acity Bcity Ccity D
  1. 1

    Pair all cities

    Pair all 2n cities exactly once.
  2. 2

    Trace unique routes

    Trace each pair’s unique path and sum its edge lengths.
  3. 3

    Minimize distance

    Choose the perfect pairing with the smallest combined route cost.
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.