#3970. [USACO23OPEN] Rotate and Shift B
[USACO23OPEN] Rotate and Shift B
题面翻译
为了庆祝春天的开始,FJ 的 头奶牛发明了一个有趣的新舞蹈。在这个舞蹈中,他们站成一个圆圈,并以一种给定的方式移动。
具体地,圆圈上有 个位置,按顺序分别编号为 至 ,其中位置 之后是位置 。每个位置都有恰好一头奶牛。奶牛也按顺序分别编号为 至 。初始状态中,编号为 的奶牛位于编号为 的位置。在圆圈上,有 个活跃位置 ,在活跃位置上的奶牛将会移动。
在舞蹈的每一分钟里,都会发生两件事。首先,在活跃位置上的奶牛会发生轮换:在 位置的奶牛移到 位置,在 位置的奶牛移到 位置……在 位置的奶牛移到 位置。所有 个移动同时发生,因此,在轮换结束后,每个活跃位置上仍有恰好一头奶牛。接下来,活跃位置会发生变换: 变为 , 变为 ,以此类推(若某个活跃位置满足 ,则 变为 )。
请求出舞蹈持续 分钟后奶牛的顺序。
输入格式
The first line contains three integers and .
The second line contains integers representing the initial set of active positions . Recall that and that these are given in increasing order.
输出格式
Output the order of the cows after minutes, starting with the cow in position , separated by spaces.
样例 #1
样例输入 #1
5 3 4
0 2 3
样例输出 #1
1 2 3 4 0
提示
For the example above, here are the cow orders and for the first four timesteps:
Initial, T = 0: order = [0 1 2 3 4], A = [0 2 3]
T = 1: order = [3 1 0 2 4]
T = 1: A = [1 3 4]
T = 2: order = [3 4 0 1 2]
T = 2: A = [2 4 0]
T = 3: order = [2 4 3 1 0]
T = 3: A = [3 0 1]
T = 4: order = [1 2 3 4 0]
, .
- Inputs 2-7: .
- Inputs 8-13: No additional constraints.