CF641C.Little Artem and Dance
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.
More detailed, there are n pairs of boys and girls standing in a circle. Initially, boy number 1 dances with a girl number 1, boy number 2 dances with a girl number 2 and so on. Girls are numbered in the clockwise order. During the dance different moves are announced and all pairs perform this moves. While performing moves boys move along the circle, while girls always stay at their initial position. For the purpose of this problem we consider two different types of moves:
- Value x and some direction are announced, and all boys move x positions in the corresponding direction.
- Boys dancing with even-indexed girls swap positions with boys who are dancing with odd-indexed girls. That is the one who was dancing with the girl 1 swaps with the one who was dancing with the girl number 2, while the one who was dancing with girl number 3 swaps with the one who was dancing with the girl number 4 and so one. It's guaranteed that n is even.
Your task is to determine the final position of each boy.
小阿尔泰姆很喜欢跳舞。他最喜欢的是“鲁埃达”(Rueda)——一种古巴舞蹈,由若干对男女围成一个圆圈共同跳起。
更具体地说,有 n 对男女围成一个圆圈站立。初始时,编号为 1 的男孩与编号为 1 的女孩配对共舞,编号为 2 的男孩与编号为 2 的女孩配对共舞,依此类推。女孩按顺时针方向编号。在舞蹈过程中,会宣布各种动作指令,所有舞伴对均需同步执行这些动作。执行动作时,男孩沿圆圈移动,而女孩始终停留在其初始位置。本题中我们只考虑以下两种动作类型:
- 宣布一个数值 x 及一个方向,所有男孩沿对应方向移动 x 个位置;
- 与偶数编号女孩共舞的男孩,与和奇数编号女孩共舞的男孩交换位置。即:原本与女孩 1 共舞的男孩与原本与女孩 2 共舞的男孩互换位置;原本与女孩 3 共舞的男孩与原本与女孩 4 共舞的男孩互换位置;以此类推。题目保证 n 为偶数。
你的任务是确定每个男孩最终所处的位置。
输入格式
The first line of the input contains two integers n and q (2 ≤ n ≤ 1 000 000, 1 ≤ q ≤ 2 000 000) — the number of couples in the rueda and the number of commands to perform, respectively. It's guaranteed that n is even.
Next q lines contain the descriptions of the commands. Each command has type as the integer 1 or 2 first. Command of the first type is given as x ( - n ≤ x ≤ n), where 0 ≤ x ≤ n means all boys moves x girls in clockwise direction, while - x means all boys move x positions in counter-clockwise direction. There is no other input for commands of the second type.
输入的第一行包含两个整数 n 和 q(2≤n≤1000000,1≤q≤2000000),分别表示“鲁埃达”(rueda)舞蹈中情侣的对数以及需要执行的指令数量。保证 n 为偶数。
接下来 q 行描述了各条指令。每条指令以整数 1 或 2 开头,表示其类型。第一类指令的形式为 x(−n≤x≤n),其中 0≤x≤n 表示所有男生沿顺时针方向移动 x 位(即跨越 x 位女生),而 −x(即 x<0)表示所有男生沿逆时针方向移动 ∣x∣ 位。第二类指令无其他输入。
输出格式
Output n integers, the i-th of them should be equal to the index of boy the i-th girl is dancing with after performing all q moves.
输出 n 个整数,其中第 i 个整数应等于在执行完全部 q 次移动后,与第 i 个女孩共舞的男孩的编号。
输入输出样例
输入#1
6 3 1 2 2 1 2
输出#1
4 3 6 5 2 1
输入#2
2 3 1 1 2 1 -2
输出#2
1 2
输入#3
4 2 2 1 3
输出#3
1 4 3 2
输入解题思路,AI测评打分。不知道怎么写?