CF - Wizard's Tour

Author: Benjamin Qi

Official Editorial (brief)

In other words, we want to pair up as many edges as possible such that the edges in each pair share a vertex.

Obviously the task can be solved independently for each component.

The answer is always for a single connected component.

Tree Case

Solution

General Case

Solution

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!

Give Us Feedback on CF - Wizard's Tour!