#P5584. 「SWTR-1」Sunny's Crystals

「SWTR-1」Sunny's Crystals

Description

Little S\mathrm{S} has nn crystals. Each crystal has an attribute did_i, which is the value of this crystal.

One day, Little A\mathrm{A} came to Little S\mathrm{S}'s home and asked Little S\mathrm{S} to arrange the crystals into a sequence, and destroy all crystals whose value is ww.

However, due to the special property of this sequence, each destruction must satisfy:

  • The crystal's position in the sequence must be a power of 22. That is, you can only destroy crystals at position 2x2^x, where 0xlog2y0 \leq x \leq \log_2 y and xx is an integer, and yy is the current number of crystals in the sequence.

After destroying one crystal, all crystals after it move forward by one position.

For example, for the value sequence 6 10 4 7 86\ 10\ 4\ 7\ 8, you can only destroy crystals at positions 1,2,41,2,4.

If you destroy the crystal at position 22, the sequence becomes 6 4 7 86\ 4\ 7\ 8.

To save time, Little S\mathrm{S} wants to know the minimum number of destructions needed to destroy all crystals with value ww, and what the initial position of the destroyed crystal is for the ii-th destruction.

This problem uses Special Judge. If there are multiple answers, you may output any one of them.

Input Format

The first line contains two integers n,wn,w.

The second line contains nn positive integers did_i.

Output Format

The first line contains an integer mm, meaning the minimum number of destructions needed to destroy all crystals with value ww.

The next line contains mm numbers. The ii-th number indicates the initial position of the crystal destroyed in the ii-th destruction, separated by spaces.

5 4
1 4 2 4 5
2
4 2
5 2
1 2 2 2 2
4
2 3 4 5
5 8
6 10 4 7 8
2
4 5

Hint


Sample Explanation

Sample 11:

First destroy the later 44, whose initial position is 44. The value sequence becomes: 1 4 2 51\ 4\ 2\ 5.

Then destroy the earlier 44, whose initial position is 22.

The total number of destructions is 22.

Sample 22:

First destroy the first 22, whose initial position is 22, and the sequence becomes: 1 2 2 21\ 2\ 2\ 2.

Then destroy the remaining first 22, whose initial position is 33, and the sequence becomes: 1 2 21\ 2\ 2.

Then destroy the first 22, whose initial position is 44, and the sequence becomes: 1 21\ 2.

Then destroy the first 22, whose initial position is 55.

The total number of destructions is 44.


Constraints and Notes

For 15%15\% of the testdata, n5n \leq 5.

For 25%25\% of the testdata, n20n \leq 20.

For 30%30\% of the testdata, n1000n \leq 1000.

For 35%35\% of the testdata, n10000n \leq 10000.

For 50%50\% of the testdata, n3×105n \leq 3 \times 10^5.

For 80%80\% of the testdata, n106n \leq 10^6.

For 100%100\% of the testdata, 1n3×106,1di400001 \leq n \leq 3 \times 10^6, 1 \leq d_i \leq 40000. It is guaranteed that the number of ww is no more than 1.5×1061.5 \times 10^6.


The shattered crystals sparkle under the sunlight...

Translated by ChatGPT 5