A1275 | [COCI-2012_2013-contest5]#5 ROTIRAJ
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mislav and Marko have devised a new game, creatively named Rotate. First, Mirko imagines a number sequence of length N and divides it into sections, with each section containing K numbers (K evenly divides N). The first section contains numbers in the first K positions in the sequence, the second section the following K positions, and so on.
Then, Marko asks Mislav to apply a number of operations on the sequence, with each operation being one of the following two types:
1. Rotate the numbers in each section to the left/right by X positions
2. Rotate the whole sequence to the left/right by X positions Notice that an operation of type 2 can change the numbers belonging to each section. After applying all the operations, Mislav reveals the final sequence to Marko. Marko's task is finding Mislav's starting sequence. He has asked you for help.
Then, Marko asks Mislav to apply a number of operations on the sequence, with each operation being one of the following two types:
1. Rotate the numbers in each section to the left/right by X positions
2. Rotate the whole sequence to the left/right by X positions Notice that an operation of type 2 can change the numbers belonging to each section. After applying all the operations, Mislav reveals the final sequence to Marko. Marko's task is finding Mislav's starting sequence. He has asked you for help.
输入格式
The first line of input contains three positive integers: N (1 ≤ N ≤ 100 000), the length of the sequence, K (1 ≤ K ≤ 100 000), the size of each section, and Q (1 ≤ Q ≤ 100 000), the number of operations.
Each of the following Q lines contains two integers: A (1 ≤ A ≤ 2), the operation type, and X (-100 000 ≤ X ≤ 100 000), the number of positions to rotate by. A negative number represents rotation to the left, while a positive one represents rotation to the right.
The last line of input contains N space-separated integers Zi (0 ≤ Zi ≤ 100 000) representing the final sequence (after applying all operations).
Each of the following Q lines contains two integers: A (1 ≤ A ≤ 2), the operation type, and X (-100 000 ≤ X ≤ 100 000), the number of positions to rotate by. A negative number represents rotation to the left, while a positive one represents rotation to the right.
The last line of input contains N space-separated integers Zi (0 ≤ Zi ≤ 100 000) representing the final sequence (after applying all operations).
输出格式
The first and only line of output must contain the required starting sequence.
输入输出样例
输入 #1
4 2 2 2 2 1 1 3 2 1 0
输出 #1
0 1 2 3
输入 #2
8 4 4 1 3 1 15 1 -5 2 -1 6 10 14 19 2 16 17 1
输出 #2
6 10 14 1 2 16 17 19
输入 #3
9 3 5 1 1 2 -8 2 9 1 1 2 -4 3 1 8 7 4 5 2 6 9
输出 #3
5 3 6 9 7 1 8 2 4
In test data worth at least 40% of total points, N will be at most 100.
In test data worth at least 70% of total points, K will be at most 100.
Clarification of the first example: The starting sequence is 0 1 2 3. After the first operations, the
sequence is 2 3 0 1, and after the second operation, it becomes 3 2 1 0. Ths corresponds to the final
sequence.
In test data worth at least 70% of total points, K will be at most 100.
Clarification of the first example: The starting sequence is 0 1 2 3. After the first operations, the
sequence is 2 3 0 1, and after the second operation, it becomes 3 2 1 0. Ths corresponds to the final
sequence.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted