#P2827. [NOIP 2016 提高组] 蚯蚓

    ID: 1884 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2016二叉堆NOIp 提高组O2优化队列

[NOIP 2016 提高组] 蚯蚓

Description

In this problem, we use the symbol c\lfloor c \rfloor to denote the floor of cc. 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 nn earthworms in the Cricket Kingdom (where nn is a positive integer). Each earthworm has a length. Let the length of the ii-th earthworm be ai(i=1,2,,n)a_i \,(i=1,2,\dots,n), and all lengths are guaranteed to be non-negative integers (i.e., earthworms with length 00 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 pp (a rational number satisfying 0<p<10 < p < 1). Suppose the length of this earthworm is xx. The master will cut it into two earthworms with lengths px\lfloor p x \rfloor and xpxx - \lfloor p x \rfloor. In particular, if either of these numbers equals 00, that earthworm of length 00 is also kept. In addition, except for the two newly created earthworms, the lengths of all other earthworms will increase by qq (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 mm seconds to arrive... (where mm is a non-negative integer).

The king wants to know the situation within these mm seconds. Specifically, he wants to know:

  • Within mm seconds, for each second, the length of the earthworm that is cut, measured just before it is cut (there are mm numbers).
  • After mm seconds, the lengths of all earthworms (there are n+mn + m 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 n,m,q,u,v,tn,m,q,u,v,t, where: the meanings of n,m,qn,m,q are as in [Description]; u,v,tu,v,t are positive integers; you need to compute p=u/vp = u / v yourself (guaranteed 0<u<v0 < u < v); tt is an output parameter, whose meaning will be explained in [Output Format].

The second line contains nn non-negative integers, namely a1,a2,,ana_1, a_2, \dots, a_n, the initial lengths of the nn earthworms.

Between any two adjacent numbers on the same line, there is exactly one space.

It is guaranteed that 1n1051 \leq n \leq 10^5, 0m7×1060 \leq m \leq 7 \times 10^6, 0<u<v1090 < u < v \leq 10^9, 0q2000 \leq q \leq 200, 1t711 \leq t \leq 71, 0ai1080 \leq a_i \leq 10^8.

Output Format

On the first line, output mt\left\lfloor \frac{m}{t} \right\rfloor integers. In chronological order, output the length (just before being cut) of the earthworm cut at time tt, 2t2t, 3t3t, … .

On the second line, output n+mt\left\lfloor \frac{n+m}{t} \right\rfloor integers: after mm seconds, output the earthworm lengths in non-increasing order, specifically the tt-th, 2t2t-th, 3t3t-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 33 earthworms are 3,3,23, 3, 2.

After 11 second: one earthworm of length 33 is cut into two earthworms of lengths 11 and 22; the other earthworms increase by 11. In the end, the 44 earthworms have lengths (1,2),4,3(1,2), 4, 3. Parentheses mean an earthworm at that position has just been cut.

After 22 seconds: one earthworm of length 44 is cut into 11 and 33. The 55 earthworms’ lengths are: 2,3,(1,3),42, 3, (1,3), 4.

After 33 seconds: one earthworm of length 44 is cut. The 66 earthworms’ lengths are: 3,4,2,4,(1,3)3, 4, 2, 4, (1,3).

After 44 seconds: one earthworm of length 44 is cut. The 77 earthworms’ lengths are: 4,(1,3),3,5,2,44, (1,3), 3, 5, 2, 4.

After 55 seconds: one earthworm of length 55 is cut. The 88 earthworms’ lengths are: 5,2,4,4,(1,4),3,55, 2, 4, 4, (1,4), 3, 5.

After 66 seconds: one earthworm of length 55 is cut. The 99 earthworms’ lengths are: (1,4),3,5,5,2,5,4,6(1,4), 3, 5, 5, 2, 5, 4, 6.

After 77 seconds: one earthworm of length 66 is cut. The 1010 earthworms’ lengths are: 2,5,4,6,6,3,6,5,(2,4)2, 5, 4, 6, 6, 3, 6, 5, (2,4). Therefore, within 77 seconds, the lengths of the cut earthworms are 3,4,4,4,5,5,63, 4, 4, 4, 5, 5, 6 in order. After 77 seconds, all earthworm lengths in non-increasing order are 6,6,6,5,5,4,4,3,2,26, 6, 6, 5, 5, 4, 4, 3, 2, 2.

Sample Explanation 2

In this testdata, only t=2t = 2 differs from the previous one. You only need to output one number every two numbers on each line.

Although the last 66 on the first line is not output, the second line must restart counting from the second number.

Sample Explanation 3

In this testdata, only t=9t = 9 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