기출 문제 / ACPC 2025 ACPC

Tree Game

A tree consisting of N vertices is given. Each vertex in the tree is numbered from 1 to N. The edges of the tree are also numbered, and the ith edge connects vertex Ai with vertex Bi, and has a weight Wi. The root of the tree is vertex 1.

Cody enjoys playing games on the tree.