Description

陣列的「旋轉」指得是把元素全部往左或往右移,並使掉出邊界外的元素從另一邊出現。現在給你一個陣列,請依照指令旋轉它!

指令有可能為:
- Q:輸出現在的陣列,以空格分開
- L <k>:將陣列往左旋轉 (每個元素往左移 $k$ 格)
- R <k>:將陣列往右旋轉 (每個元素往右移 $k$ 格)
- S <i> <x>:將目前陣列的第 $i$ 個值設為 $x$
- E:代表輸入結束

Input Format

第一行有一個數字 $n$ 代表陣列長度
第二行則有 $n$ 個數字 $a_n$,為陣列初始數值
接下來有不定數量 $q$ 行,為要執行的指令

條件:

$0 < n < 1000$
$0 < q < 1000$
$0 \le a_n < 2^{31}\ \forall n \in \mathbb N$
$0 \le k < 2^{31}$
$0 \le i < n$

Output Format

詳見輸入格式

Sample Input 1

5
1 2 3 4 5
Q
L 2
Q
R 3
S 3 7
L 4
Q
E

Sample Output 1

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

Sample Input 2

3
7 8 9
S 1 1000
R 1000
Q
L 5
Q
E

Sample Output 2

9 7 1000
1000 9 7

Hints

Problem Source

又有裸題 好欸

TopCoder


$\texttt{<script>alert(":3");</script>}$

User's AC Ratio

100.0% (1/1)

Tags

Problem Setter

Created by

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 10
2 2~3 $k < n$,且不會出現 L 指令 15
3 4~5 $k < n$ 15
4 6~9 60

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 1
2 1000 65536 65536 2
3 1000 65536 65536 2
4 1000 65536 65536 3
5 1000 65536 65536 3
6 1000 65536 65536 4
7 1000 65536 65536 4
8 1000 65536 65536 4
9 1000 65536 65536 4