QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#7946. Black Box

Statistics

以下 Python 风格的伪代码函数 BlackBox() 接收一个正整数列表,并以特定方式对列表中的整数进行洗牌,最后返回结果列表。

下方使用了三个列表方法:对于列表 Llen(L) 返回 L 中元素的个数;L.append(x) 将元素 x 添加到 L 的末尾;L.pop(idx) 从列表 L 中移除指定索引 idx 处的元素并返回该元素。

给定一个正整数列表 Z,请编写一个程序来重构列表 I,使得 Z = BlackBox(I)

function BlackBox( Banana ):
 if len( Banana ) <= 4 :
 exit("Too small Banana")
 Apple = [] # [] is an empty list
 Mango = 0
 Papaya = len( Banana )
 while( Papaya >= 2 ) :
 Kiwi = Banana[ Mango ]
 Apple.append( Kiwi )
 Banana.pop( Mango )
 Papaya = Papaya - 1
 Mango = ( Kiwi + Mango - 1 ) % Papaya
 # end of while
 Apple.append( Banana[ 0 ] )
 Pear = len( Apple ) - 1
 Orange = Apple[ Pear ]
 Lime = Apple[ 0 ]
 Coconut = Orange % Pear
 Melon = Apple[ Coconut ]
 Apple[ 0 ] = Melon
 Apple[ Coconut ] = Lime
 return ( Apple )
# end of function BlackBox

输入格式

程序从标准输入读取数据。第一行包含一个正整数 $n$,表示列表 Z 中正整数的个数,其中 $5 \le n \le 200,000$。接下来的 $n$ 行包含 BlackBox(I) 返回的列表 Z 中的 $n$ 个正整数;第 $i$ 行包含列表 Z 的第 $i$ 个整数,数值在 1 到 100,000 之间(含边界)。

输出格式

程序向标准输出写入数据。打印列表 I 中的 $n$ 个整数,使得 Z = BlackBox(I),每行一个整数;第 $i$ 行应包含 I 的第 $i$ 个整数。

样例

输入 1

13
113
49
68
91
10
179
2
71
78
45
57
10
88

输出 1

10
113
179
68
57
45
10
2
88
71
49
78
91

输入 2

9
6
8
7
9
5
1
2
4
3

输出 2

9
8
7
6
5
1
2
3
4

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.