← CSES Better

Superbull

USACO · 2015 · February · silver-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

graph-algorithms · maximum-spanning-tree

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

sample trace

Superbull: maximum spanning tree

Treat teams as vertices and XOR scores as edge weights. The maximum spanning tree chooses connections totaling 37.

vertices

36910

selected Edges

  • from
    6
    to
    9
    weight
    15
  • from
    6
    to
    10
    weight
    12
  • from
    3
    to
    9
    weight
    10

total

37
  1. 1

    Create weighted edges

    For every team pair, use the XOR of their IDs as the edge weight.
  2. 2

    Grow the tree

    Prim?s algorithm repeatedly adds the highest-weight edge connecting the current tree to a new team.
  3. 3

    Sum chosen scores

    Edges 6-9 (15), 6-10 (12), and 3-9 (10) connect all teams for 37 points.
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.