#P14086. [ICPC 2023 Seoul R] Black Box
[ICPC 2023 Seoul R] Black Box
题目描述
The following -like pseudo code for function takes a list of positive integers and shuffles the integers in the list in a specific way, and returns the result as a list.
Three list methods are used below; For a list L
, len(L)
returns the number of items in L
. L.append(x)
adds the item x
to the end of L
. L.pop(idx)
removes the item at the specified index idx
from the list L
and
returns the removed item.
Given a list of positive integers, write a program to reconstruct a list such that .
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
输入格式
Your program is to read from standard input. The first line contains a positive integer representing the number of positive integers of a list , where . The following lines contain positive integers of the list returned from ; the -th line contains the -th integer of the list between and , both inclusive.
输出格式
Your program is to write to standard output. Print integers of the list where , one per line; the -th line should contain the -th integer of .
13
113
49
68
91
10
179
2
71
78
45
57
10
88
10
113
179
68
57
45
10
2
88
71
49
78
91
9
6
8
7
9
5
1
2
4
3
9
8
7
6
5
1
2
3
4