#P10058. Reverse and Rotate
Reverse and Rotate
Problem Description
Given a string and operations, each operation is one of the following three types:
-
< xmeans cyclically shift to the left by positions. For example, becomes after< 2. -
> xmeans cyclically shift to the right by positions. For example, becomes after> 2. -
revmeans reverse . For example, becomes afterrev.
Find the string obtained after performing these operations in order.
Note: For , cyclically shifting it left by positions becomes ; cyclically shifting it right by positions becomes . For , we have .
Input Format
The first line contains a string .
The second line contains an integer .
The next lines each contain one operation.
Output Format
Output one line containing a string , which is the string obtained after performing the operations in order.
abcde
3
> 2
rev
< 2
aedcb
Hint
[Sample 1 Explanation]
- The original string is .
- After the first operation, the string becomes .
- After the second operation, the string becomes .
- After the third operation, the string becomes .
[Constraints]
Let denote the length of string .
| Test Point ID | Special Property |
|---|---|
There is no rev operation. |
|
| None. |
For of the testdata, , , and consists only of lowercase letters.
Translated by ChatGPT 5