A. 【例57.3】火星人

    Type: Default 1000ms 125MiB

【例57.3】火星人

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

Humans have finally set foot on Mars and encountered mysterious Martians. Neither humans nor Martians can understand each other's language, but our scientists have invented a method of communication using numbers. This method works as follows: first, a Martian tells a human scientist a very large number. After the scientist deciphers the meaning of this number, they add a small number to it and tell the result to the Martian as a human response.
Martians represent numbers in a very simple way—by counting on their fingers. A Martian has only one hand, but this hand has thousands of fingers, arranged in a row and numbered 11, 22, 33, and so on. Martians can freely swap the positions of any two fingers, and this is how they count.
A Martian demonstrated how to count on fingers using a human hand. If five fingers—thumb, index, middle, ring, and little finger—are numbered 11, 22, 33, 44, and 55, respectively, when arranged in the normal order, they form the 55-digit number 1234512345. When you swap the ring and little fingers, it forms the 55-digit number 1235412354. When you completely reverse the order of the five fingers, it forms 5432154321. Among all possible 120120 55-digit numbers, 1234512345 is the smallest, representing 11; 1235412354 is the second smallest, representing 22; and 5432154321 is the largest, representing 120120. The table below shows the 66 33-digit numbers that can be formed with only 33 fingers and the numbers they represent:
Ternary numbers 123132213231312321123132213231312321 represent numbers 123456123456.
Now, you have the honor of being the first Earthling to communicate with a Martian. A Martian will show you their fingers, and a scientist will tell you a small number to add. Your task is to add the number represented by the Martian's fingers to the number told by the scientist and change the order of the Martian's fingers according to the result. The input data guarantees that this result will not exceed the range that the Martian's fingers can represent.

Input Format

Three lines: the first line contains a positive integer NN, representing the number of Martian fingers (1N100001≤N≤10000). The second line contains a positive integer MM, representing the small integer to be added (1M1001≤M≤100). The next line contains a permutation of the NN integers from 11 to NN, separated by spaces, representing the order of the Martian's fingers.

Output Format

A single line containing NN integers, representing the new order of the Martian's fingers. Each adjacent pair of numbers should be separated by a single space, with no extra spaces.

Sample

5
3
1 2 3 4 5
1 2 4 5 3

20251018C班作业(3)

Not Claimed
Status
Done
Problem
5
Open Since
2025-10-23 0:00
Deadline
2025-10-30 23:59
Extension
24 hour(s)