QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 10

#6027. 洗牌 [B]

Statistiques

Bajtazar 学会了一种引人注目的递归洗牌程序。对于由两张牌组成的牌堆,洗牌过程仅仅是交换这两张牌的顺序。对于由 $2^k$ ($k \ge 2$) 张牌组成的牌堆,洗牌过程如下:首先,将牌堆平分为上下两部分。然后,分别对这两部分(每部分包含 $2^{k-1}$ 张牌)进行递归洗牌,最后将洗好牌的下半部分放在洗好牌的上半部分之上。

Bajtazar 拥有一副由 $2^n$ 张牌组成的牌堆,每张牌上都写有一个数字。Bajtazar 重复执行上述洗牌程序 $t$ 次。他想知道在所有洗牌操作完成后,牌堆中从上到下各张牌上的数字分别是多少。

输入格式

第一行包含两个整数 $n$ 和 $t$ ($1 \le n \le 20, 1 \le t \le 10^9$)。 第二行包含 $2^n$ 个整数 $a_1, \dots, a_{2^n}$ ($1 \le a_i \le 10^9$),$a_i$ 表示 Bajtazar 牌堆中从上往下数第 $i$ 张牌上的数字。

输出格式

在唯一的一行中输出 $2^n$ 个整数,表示 $t$ 次洗牌后牌堆中从上到下各张牌上的数字。

样例

样例输入 1

2 1
2 4 1 5

样例输出 1

5 1 4 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.