#P6324. [COCI 2006/2007 #4] JOGURT
[COCI 2006/2007 #4] JOGURT
Problem Description
You are given a complete binary tree with a total of levels.
We label the root as being on level . The two children of the root are on level , and so on.
Now, we need to fill the numbers from to into the nodes, with no repetition and no omission, such that for any , if we take a node on level as the root of a subtree, then the absolute value of the difference between the sum of numbers in its left subtree and the sum of numbers in its right subtree is equal to .
Please output one feasible assignment. You only need to output the preorder traversal of this assignment.
Input Format
One line with one integer , representing the number of levels of the tree.
Output Format
Output one line with integers from to , separated by spaces, representing one possible preorder traversal.
If there are multiple answers, output any one of them. This problem uses SPJ.
2
3 1 2
3
3 1 7 5 6 2 4
Hint
Constraints
For of the testdata, it is guaranteed that .
Notes
This problem is translated from COCI2006-2007 CONTEST #4 T5 JOGURT.
Thanks to @一扶苏一 for providing the SPJ.
Translated by ChatGPT 5