Particle Accelerator
Time limit5sMemory limit2048 MB
The accelerator is a tree of N rooms, and the task makes Q calls to generate with distinct room values v, but the statement never says what generate must return.
Problem
The KOI research institute runs experiments with a particle accelerator. The accelerator has rooms and two-way passages that connect them. Any two distinct rooms can reach each other using only passages, so the accelerator forms a tree.
Rooms are numbered with distinct integers from to , and passages are numbered with distinct integers from to . For every , passage connects room and room .
Constraints
- The accelerator forms a tree.
- For all , and ().
- For every call to the
generatefunction, , and each is a different value.