QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#9249. Elimination Series Once More

統計

$2^n$ contestants take part in a programming contest. They are labeled from $1$ to $2^n$, and the contestant labeled $i$ has a level of $a_i$. It is guaranteed that $a_1, a_2, \dots, a_{2^n}$ forms a permutation of length $2^n$ (i.e., each $a_i$ is an integer in the range $[1, 2^n]$, and $a_1, a_2, \dots, a_{2^n}$ are pairwise distinct).

The contest takes the form of an elimination series. There are $n$ rounds; each round will knock out exactly half of the contestants. In each round, let $m$ be the current number of contestants, then the contestant with the smallest label (i.e., the label of each contestant remains unchanged throughout the contest) competes with the contestant with the second smallest label, the contestant with the third smallest label competes with the contestant with the fourth smallest label, and so on. In each competition, the contestant with a lower level is eliminated, while the contestant with a higher level will advance to the next round.

Little D is the contestant labeled $x$. He wants to use magic before the contest to win as many competitions as possible. Specifically, he can perform the following operation no more than $k$ times: choose two contestants other than himself and swap their levels. Note that the operation can only be done before the contest.

For each $x = 1, 2, \dots, 2^n$, print the maximum number of competitions he can win.

Input

The first line contains two integers $n$ ($1 \le n \le 20$) and $k$ ($0 \le k < 2^n$). The second line contains $2^n$ integers $a_1, a_2, \dots, a_{2^n}$. It is guaranteed that $a$ is a permutation.

Output

For each $x = 1, 2, \dots, 2^n$, print the maximum number of competitions Little D can win.

Examples

Input 1

2 1
1 2 3 4

Output 1

0 1 1 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.