QOJ.ac

QOJ

実行時間制限: 15 s メモリ制限: 512 MB 満点: 100

#7337. 蚱蜢

統計

在草地上休息时,你注意到了一场不可思议的奇观:一群蚱蜢正在圆圈上跳跃。你发现这场舞蹈非常优美,因为你意识到它们的移动并非随机,而是遵循某种数学规律。

圆圈上标记了 $m$ 个点。这些点按在圆圈上出现的顺序编号为 $1$ 到 $m$,并将圆圈平分为长度相等的弧。其中一些点上有蚱蜢,同一个点上可能有多只蚱蜢。蚱蜢编号为 $1$ 到 $n$。每秒钟,蚱蜢会根据以下规则跳跃到新的位置:如果在这一秒开始时,蚱蜢 $1, 2, \dots, n$ 分别站在点 $A_1, A_2, \dots, A_n$ 上,且 $O$ 为圆心,那么在这一秒结束时,蚱蜢将站在位置 $B_1, B_2, \dots, B_n$ 上,其中对于 $k = 1, 2, \dots, n-1$,$B_k$ 是点 $A_k$ 关于直线 $OA_{k+1}$ 的对称点,$B_n$ 是点 $A_n$ 关于直线 $OA_1$ 的对称点。蚱蜢的编号不一定对应它们在圆圈上的顺序,且在舞蹈过程中编号保持不变。

你现在需要回家了,但你很好奇之后会发生什么。给定蚱蜢的初始排列,求它们在 $t$ 秒后的位置。

输入格式

输入的第一行包含测试用例的数量 $z$ ($1 \le z \le 10^9$)。接下来是各测试用例的描述。

每个测试用例的第一行包含三个整数 $n, m, t$ ($1 \le n \le 100\,000, 3 \le m \le 100, 1 \le t \le 10^9$):蚱蜢的数量、弧的数量和秒数。第二行包含 $n$ 个整数,表示蚱蜢的初始位置。位置是 $1$ 到 $m$ 之间的整数(包含 $1$ 和 $m$)。所有测试用例中蚱蜢的总数不超过 $200\,000$。

输出格式

对于每个测试用例,输出 $t$ 秒后蚱蜢的位置,用空格分隔。

样例

输入 1

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

输出 1

1 3 5
5 4 5

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.