#P5584. Crystal Destruction

    ID: 18814 Type: Default 1000ms 256MiB

Crystal Destruction

Crystal Destruction

You are given a collection of n crystals. Each crystal has an attribute (d_i) representing its value. One day, Little A visits Little S and asks him to arrange the crystals in a sequence and then destroy all crystals whose value is equal to a given integer (w). However, there is a twist in the destruction process. Due to the special nature of the sequence, every time you destroy a crystal, its position in the current sequence must be a power of two. Formally, if the current sequence contains (y) crystals, you are only allowed to destroy the crystal at position (2^x) where (0 \le x \le \log_2 y) and (x) is an integer. When a crystal is destroyed, all crystals that were to its right shift one position to the left.

For example, if the initial crystal value sequence is

(6\quad 10\quad 4\quad 7\quad 8),

you can only destroy crystals at positions (1, 2, 4) (since (2^0=1,, 2^1=2,, 2^2=4)). If you destroy the crystal at position 2, the sequence becomes

(6\quad 4\quad 7\quad 8).

Little S can arrange the crystals in any order he likes before the destruction process. His goal is to find an arrangement and a sequence of destruction moves such that all crystals with value (w) are destroyed using the minimum number of moves. Moreover, you are required to output the original positions (in the arranged sequence) of the crystals destroyed in each move. Since you can choose the arrangement arbitrarily, an optimal strategy is to place all crystals with value (w) at the beginning of the sequence. Then, by always destroying the crystal at position 1 (which is always allowed because (1 = 2^0)), you can remove one (w) crystal per move. Thus, the minimum number of moves is exactly the number of crystals with value (w), and the destruction moves will remove the crystals originally at positions (1, 2, \ldots, m) (where (m) is the count of crystals whose value equals (w)).

Your task is to implement a program that, given the input, outputs the minimum number of moves required and the list of original positions (in the arranged sequence) of the crystals destroyed in each move.

Note: This problem uses a special judge. If there are multiple valid answers, output any one of them.

inputFormat

The first line contains two integers (n) and (w) ((1 \le n \le 10^5), (w) is an integer). The second line contains (n) integers (d_1, d_2, \ldots, d_n), where each (d_i) represents the value of a crystal.

Note that you are allowed to rearrange the crystals arbitrarily before performing the destructions.

outputFormat

The first line should contain a single integer representing the minimum number of moves required (which is the number of crystals with value (w)). The second line should contain that many integers: the original positions (in the arranged sequence) of the crystals you decide to destroy in order. If there are no crystals with value (w), simply output 0 in the first line.

sample

5 4
6 10 4 7 8
1

1

</p>