#63659. [ USACO 2023 Open Bronze]Rotate and Shift
[ USACO 2023 Open Bronze]Rotate and Shift
暂无测试数据。
英文题面
To celebrate the start of spring, Farmer John's $N$ cows $(1\leq N\leq 2⋅10^5)$ have invented an intriguing new dance, where they stand in a circle and re-order themselves in a predictable way.
Specifically, there are $N$ positions around the circle, numbered sequentially from $0$ to $N−1$, with position 00 following position $N−1$. A cow resides at each position. The cows are also numbered sequentially from $0$ to $N−1$. Initially, cow $i$ starts in position $i$. You are told a set of $K$ positions $0=A_1<A_2<…<A_K<N$ that are "active", meaning the cows in these positions are the next to move $(1≤K≤N)$.
In each minute of the dance, two things happen. First, the cows in the active positions rotate: the cow at position $A_1$moves to position $A_2$, the cow at position $A_2$ moves to position $A_3$, and so on, with the cow at position $A_K$ moving to position $A1$. All of these K moves happen simultaneously, so the after the rotation is complete, all of the active positions still contain exactly one cow. Next, the active positions themselves shift: $A1$ becomes $A_1+1$,$ A_2$ becomes $A_2+1$, and so on (if $A_i=N−1$ for some active position, then $A_i$ circles back around to $0$).
Please calculate the order of the cows after $T$ minutes of the dance ($1≤T≤10^9$).
译文
为了庆祝春天的开始,约翰农夫的 $N$ 头奶牛 $(1\leq N\leq 2⋅10^5)$ 发明了一种有趣的新舞蹈,它们站成一个圆圈并以可预测的方式重新排列。
具体来说,圆圈上有 $N$ 个位置,从 $0$ 到 $N-1$ 进行顺序编号,位置 $0$ 紧接着位置 $N-1$。每个位置都有一头奶牛。奶牛也按顺序从 $0$ 到 $N-1$ 进行编号。初始时,奶牛 $i$ 位于位置 $i$。你得知了一组 $K$ 个位置 $0=A_1<A_2<…<A_K<N$,它们是“活动”的,意思是这些位置上的奶牛是下一个要移动的 $(1≤K≤N)$。
在舞蹈的每一分钟里,会发生两件事。首先,活动位置上的奶牛进行旋转:位于位置 $A_1$ 的奶牛移动到位置 $A_2$,位于位置 $A_2$ 的奶牛移动到位置 $A_3$,依此类推,位于位置 $A_K$ 的奶牛移动到位置 $A_1$。所有这 $K$ 次移动同时进行,因此在旋转完成后,所有活动位置上仍然恰好包含一头奶牛。接下来,活动位置本身也会发生移动:$A_1$ 变为 $A_1+1$,$A_2$ 变为 $A_2+1$,依此类推(如果某个活动位置的 $A_i=N-1$,则 $A_i$ 回到 $0$)。
请计算舞蹈进行 $T$ 分钟后,奶牛的顺序($1≤T≤10^9$)。
输入格式
The first line contains three integers $N$, $K$, and $T$. The second line contains $K$ integers representing the initial set of active positions $A_1,A_2,…A_K$. Recall that $A_1=0$ and that these are given in increasing order.
第一行包含三个整数 $N$、$K$ 和 $T$。
第二行包含 $K$ 个整数,表示初始的活动位置集合 $A_1,A_2,…A_K$。请记住 $A_1=0$,并且这些位置按升序给出。
输出格式
Output the order of the cows after $T$ minutes, starting with the cow in position $0$ , separated by spaces.
输出经过 $T$ 分钟后奶牛的顺序,从位置 $0$ 开始,用空格分隔。
数据范围
Inputs 2-7: $N\leq 1000,T\leq 10000$
Inputs 8-13: No additional constraints.
输入 2-7:$N\leq 1000,T\leq 10000$
输入 8-13:没有额外的限制。
5 3 4
0 2 3
1 2 3 4 0