#P2827. [NOIP 2016 提高组] 蚯蚓
[NOIP 2016 提高组] 蚯蚓
Description
In this problem, we use the symbol to denote the floor of . For example, $\lfloor 3.0 \rfloor = \lfloor 3.1 \rfloor = \lfloor 3.9 \rfloor = 3$.
The Cricket Kingdom is suffering from an earthworm outbreak! Even the fleas from the neighboring Flea Kingdom can’t handle the earthworms. The Cricket King has no choice but to invite the Divine Blade Master to help eliminate them.
There are currently earthworms in the Cricket Kingdom (where is a positive integer). Each earthworm has a length. Let the length of the -th earthworm be , and all lengths are guaranteed to be non-negative integers (i.e., earthworms with length may exist).
Every second, the Divine Blade Master will accurately find the longest earthworm among all earthworms (if there are multiple, choose any one) and cut it in half. The cutting position is determined by a constant (a rational number satisfying ). Suppose the length of this earthworm is . The master will cut it into two earthworms with lengths and . In particular, if either of these numbers equals , that earthworm of length is also kept. In addition, except for the two newly created earthworms, the lengths of all other earthworms will increase by (a non-negative integer constant).
The Cricket King knows this is not a long-term solution, because not only will the number of earthworms increase, but they will also become longer. The king decides to seek help from a mysterious figure with great power, but the reinforcements will take seconds to arrive... (where is a non-negative integer).
The king wants to know the situation within these seconds. Specifically, he wants to know:
- Within seconds, for each second, the length of the earthworm that is cut, measured just before it is cut (there are numbers).
- After seconds, the lengths of all earthworms (there are numbers).
Of course, the Cricket King knows how to do this! But he wants to test you.
Input Format
The first line contains six integers , where: the meanings of are as in [Description]; are positive integers; you need to compute yourself (guaranteed ); is an output parameter, whose meaning will be explained in [Output Format].
The second line contains non-negative integers, namely , the initial lengths of the earthworms.
Between any two adjacent numbers on the same line, there is exactly one space.
It is guaranteed that , , , , , .
Output Format
On the first line, output integers. In chronological order, output the length (just before being cut) of the earthworm cut at time , , , … .
On the second line, output integers: after seconds, output the earthworm lengths in non-increasing order, specifically the -th, -th, -th, … largest lengths.
Between any two adjacent numbers on the same line, there is exactly one space. Even if a line has no numbers to output, you must still output a blank line.
Please read the samples to better understand this format.
3 7 1 1 3 1
3 3 2
3 4 4 4 5 5 6
6 6 6 5 5 4 4 3 2 2
3 7 1 1 3 2
3 3 2
4 4 5
6 5 4 3 2
3 7 1 1 3 9
3 3 2
//空行
2
Hint
Sample Explanation 1
Before the Divine Blade Master arrives: the lengths of earthworms are .
After second: one earthworm of length is cut into two earthworms of lengths and ; the other earthworms increase by . In the end, the earthworms have lengths . Parentheses mean an earthworm at that position has just been cut.
After seconds: one earthworm of length is cut into and . The earthworms’ lengths are: .
After seconds: one earthworm of length is cut. The earthworms’ lengths are: .
After seconds: one earthworm of length is cut. The earthworms’ lengths are: .
After seconds: one earthworm of length is cut. The earthworms’ lengths are: .
After seconds: one earthworm of length is cut. The earthworms’ lengths are: .
After seconds: one earthworm of length is cut. The earthworms’ lengths are: . Therefore, within seconds, the lengths of the cut earthworms are in order. After seconds, all earthworm lengths in non-increasing order are .
Sample Explanation 2
In this testdata, only differs from the previous one. You only need to output one number every two numbers on each line.
Although the last on the first line is not output, the second line must restart counting from the second number.
Sample Explanation 3
In this testdata, only differs from the previous one.
Note that there are no numbers to output on the first line, but you must still print a blank line.
Constraints

Translated by ChatGPT 5
京公网安备 11011102002149号