#P15763. [JAG 2025 Summer Camp #1] Billion Tree
[JAG 2025 Summer Camp #1] Billion Tree
题目描述
This is an interactive problem.
The interaction consists of two phases.
Phase 1
You must first choose an integer (). Then you must output the chosen and a tree on vertices satisfying the following conditions:
- The vertices are numbered .
- Each edge of has an integer weight between and , inclusive.
Phase 2
You are given an integer , followed by integers . For each (), you must express as the sum of the weights of at most 5 paths in .
Formally, for each you must output:
- an integer (),
- and pairs of vertices ,
such that
$$\begin{aligned} \sum_{j=1}^{K} w(u_j, v_j) = x_i, \end{aligned}$$where denotes the weight of the path between vertices and in .
The weight of a path is defined as the sum of the weights of the edges contained in the path.
Interaction
The interaction proceeds as follows:
Phase 1
Choose an integer and a weighted tree , and output them in the following format:
$$\begin{aligned} & N \\ & a_1 \ b_1 \ c_1 \\ & \vdots \\ & a_{N-1} \ b_{N-1} \ c_{N-1} \end{aligned}$$Each triple represents an edge between vertices and with weight . The following conditions must hold:
Phase 2
First, an integer () is given. Then, integers () are given one by one. For each integer , you must output your answer in the following format:
$$\begin{aligned} & K \\ & u_1 \ v_1 \\ & \vdots \\ & u_K \ v_K \end{aligned}$$Here () is the number of paths, and each pair represents a path between vertices and .
Note that the value () is provided only after the answer for has been printed.
Notes on Interactive Judging
The verdict will be indeterminate if there is malformed output during the interaction or your program quits prematurely. Terminate the program immediately after printing the answer, or the verdict will be indeterminate. As some environments require flushing the output buffers, make sure that your outputs are actually sent. Otherwise, your outputs will never reach the judge.
3
110
210
20
3
1 2 10
3 1 100
1
2 3
3
2 1
1 3
1 3
2
1 2
1 2