#P10857. 【MX-X2-T6】「Cfz Round 4」Ad-hoc Master
【MX-X2-T6】「Cfz Round 4」Ad-hoc Master
Background
I do not need to be so fired up every day,
but I can keep living while searching for you.
Problem Description
Given a positive integer . We define .
Now, for every positive integer not greater than and every positive integer not greater than , the value of is given. You need to construct a pair satisfying , , such that there exists a full binary tree with levels satisfying:
- The labels of all nodes in the full binary tree form a permutation of , and each node has a weight.
- The root of the full binary tree is node .
- The weight of each node in the full binary tree is a non-negative integer less than , and the weight of the root node is .
- For every positive integer not greater than and every positive integer not greater than , the xor sum of the weights of all nodes satisfying is . In particular, if there is no node satisfying the condition, then must hold.
Here, is the number of edges on the simple path between node and node . In particular, .
It is guaranteed that there exists at least one pair that satisfies the requirements.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
Then each test case is given as follows. For each test case:
- The first line contains a positive integer .
- The next lines: line contains integers, where the -th integer represents the value of .
Output Format
For each test case, output one line with two integers, representing and in your constructed pair .
- If your constructed pair satisfies the requirements, you get of the score for that test point.
- Otherwise, if your constructed pair does not satisfy the requirements, but there exists a valid pair such that , you get of the score for that test point.
- Otherwise, if your constructed pair does not satisfy the requirements, but there exists a valid pair such that , you get of the score for that test point.
- Otherwise, you get no score for that test point.
2
2
1 0
2 0
1 2
4
75 0 89 1 0 56
0 52 19 84 1 0
0 27 19 108 1 0
0 89 1 0 56 0
85 19 108 1 0 0
75 0 89 1 0 56
1 1 56 0 0 0
0 88 19 84 1 0
0 79 19 108 1 0
74 0 88 1 0 56
0 88 1 0 56 0
109 19 84 1 0 0
19 56 1 0 0 0
74 0 88 1 0 56
18 1 0 56 0 0
2 1
7 19
Hint
[Sample Explanation #1]
For the first test case:
When the constructed pair , there exists a binary tree as shown in the figure that satisfies the requirements, where the weights of nodes are respectively.

When you output 2 2, you can get of the score for that test point, because although does not satisfy the requirements, there exists a valid pair such that .
When you output 1 1, you can also get of the score.
But when you output 1 2, you will get no score for that test point.
[Constraints]
Let denote the sum of within a single test point.
For all testdata, , , , , and it is guaranteed that there exists at least one valid pair .
This problem uses bundled judging.
- Subtask 1 (20 points): .
- Subtask 2 (20 points): Satisfies a special property.
- Subtask 3 (60 points): No special restrictions.
Special property: There exists a pair satisfying , , and based on this, there exists a full binary tree that satisfies the requirements, where the weights of all nodes are equal to .
Translated by ChatGPT 5