This is an interactive problem.
There is a tree with $n$ nodes rooted at $1$. For each query, you provide a set $T$. Let $S_u$ denote the set of nodes in the subtree of $u$, and $d(u, v)$ denote the number of edges on the path between $u$ and $v$. The interactor returns:
$$V=\{x \mid \exists u\in T,x\in S_u\}\\D(T)=\sum_{i\in V,j\in V,i < j}d(i,j)$$
If the tree you return is isomorphic to the actual tree, you will receive $40\%$ of the points.
Implementation Details
You need to implement std::vector<int> solve(int n);, where $n$ is the number of nodes. The returned vector should store the parent of each node from $2$ to $n$ in order. Note: It is not guaranteed that the parent's index is smaller than the child's index.
You can use int query(std::vector<int> T); to perform a query as described above.
During official evaluation, the interactor only includes anti-cheating measures; its efficiency is the same as the provided file.
For local testing, the interactor reads: the first line contains an integer $n$, and the second line contains $n-1$ integers representing the parents of nodes $2$ to $n$, respectively.
Examples
Input 1
6 1 2 3 1 2
Output 1
query({1})=31
query({3,5})=8
query({3})=1Note
{1,2,3,1,2}: score=1.0
{1,2,3,2,1}: score=0.4
{1,1,1,1,1}: score=0.0Constraints and Subtasks
$n\le 1000$, where $T$ represents the upper bound on the number of queries.
- A: The tree is a binary tree.
- B: The tree is random. The generation method is: generate a random permutation $p$ such that $p_1=1$, then for each $i$, choose the parent $f_{p_i}$ uniformly at random from $\{p_1, \dots, p_{i-1}\}$.
| $n$ | $T$ | Score | Special Property |
|---|---|---|---|
| $5$ | $1\,000$ | $5$ | |
| $100$ | $10^5$ | $5$ | |
| $5\,000$ | $10$ | ||
| $1\,000$ | $2\times 10^5$ | $10$ | |
| $10^5$ | $10$ | A | |
| $10$ | B | ||
| $10$ | |||
| $5 \times 10^4$ | $10$ | A | |
| $10$ | B | ||
| $10$ | |||
| $3 \times 10^4$ | $10$ |