This page is still under construction.

Parts of this page are still being built. What you see may change.

Sort It Out

Time limit2sMemory limit512 MB

Summary
Find the smallest subset of cow IDs S such that repeatedly yelling at each ID in S in increasing order eventually sorts the permutation, then output the K-th lexicographically smallest such subset.
Level

Hard8 of 10

Topics
Sorting, Combinatorics, Greedy, Brute force
Solved
No attempts yet

Problem

FJ has NN (1≤N≤1051 \leq N \leq 10^5) cows, distinctly identified 1…N1 \ldots N, lined up in a row. FJ likes his cows to be sorted in increasing order, but unfortunately they are currently out of order. In the past FJ used algorithms such as "bubble sort" to sort his cows, but today he feels quite lazy. Instead he will yell at one specific cow at a time to "sort it out". When yelled at, a cow makes sure she is not out of order from her point of view. While there is a cow immediately to her right with a smaller ID, the two swap places. Then, while there is a cow immediately to her left with a larger ID, the two swap places. Finally the cow is done "sorting it out", at which point the cow to her left has a smaller ID and the cow to her right has a larger ID.

FJ wants to pick a subset of cows, then iterate through this subset yelling at each of them in turn in increasing order of ID, again and again until all NN cows are sorted. For instance, if he picks the subset of cows with IDs {2,4,5}\{2, 4, 5\}, he will yell at cow 22, then cow 44, then cow 55. If the NN cows are still not sorted, he will yell at these same cows again, as many times as necessary.

Since FJ is not sure which cows are paying attention, he wants to minimize the size of this subset. FJ also thinks the number KK is very lucky. Help him find the KK-th lexicographically smallest subset of minimal size such that shouting at its cows repeatedly will eventually result in all cows being sorted.

A subset SS of {1,…,N}\{1,\dots,N\} is lexicographically smaller than a subset TT if the list of elements of SS in increasing order is lexicographically smaller than the list of elements of TT in increasing order. For instance, {1,3,6}\{1, 3, 6\} is lexicographically smaller than {1,4,5}\{1, 4, 5\}.

Input

The first line contains two integers, NN and KK (1≤K≤10181 \leq K \leq 10^{18}). The second line contains NN space-separated integers, the cows' numbers from left to right.

It is guaranteed that there are at least KK valid subsets.

Output

The first line of output contains the size of the minimal subset. The remaining lines contain the IDs of the cows in the KK-th lexicographically smallest subset of minimal size, one ID per line, listed in increasing order.

Hint

We start with the array  4   2   1   3 \mathtt{\:4\:\; 2\:\; 1\:\; 3\:}. After FJ yells at the cow with ID 1, the array becomes  1   4   2   3 \mathtt{\:1\:\; 4\:\; 2\:\; 3\:}. When FJ yells at the cow with ID 4, the array becomes  1   2   3   4 \mathtt{\:1\:\; 2\:\; 3\:\; 4\:}. At this point the array is sorted.

Examples1

  1. Example 1

    Input
    4 1
    4 2 1 3
    
    Expected output
    2
    1
    4