Logo
(追記) (追記ここまで)

19100번 - Shuffle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB1671138268.908%

문제

Byteasar has learnt a fabulous recursive method of shuffling a deck of cards. This algorithm can be described as follows:

  • In order to shuffle two cards, swap them.
  • In order to shuffle 2ドル^k$ cards ($k \geq 2$), split them into two equal parts -- an upper one and a lower one (so that each of them has 2ドル^{k - 1}$ cards). Shuffle each of them recursively and then put the lower half on the top of the upper half.

Byteasar has a deck of 2ドル^n$ cards. Each of them has a number written on it. Byteasar now shuffles the deck, running the procedure described above exactly $t$ times. As it might take a great amount of time, he would like to know the final order of the cards beforehand.

입력

The first line of the input contains two integers $n, t$ (1ドル \le n \le 20,ドル 1ドル \le t \le 10^9$). The second line contains 2ドル^n$ integers $a_1, \dots, a_{2^n}$ (1ドル \le a_i \le 10^9$); $a_i$ is the number written on the $i$-th topmost card in the deck.

출력

In the first and only line of output print 2ドル^n$ integers -- the numbers written on the cards of Byteasar's deck after $t$ shuffles. Print the numbers in the order from the topmost to the bottommost card.

제한

예제 입력 1

2 1
2 4 1 5

예제 출력 1

5 1 4 2

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 6: Warsaw U Contest, XVII OpenCup Onsite K번

Contest > Algorithmic Engagements > PA 2016 1-2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /