#P48. [KBC003Ex] Sequence 4
[KBC003Ex] Sequence 4
Source
This problem is adapted from Long Long OJ. All rights reserved.
Attention
The time limit for this problem is 10 seconds.
Problem Description
Given a sequence containing elements, perform operations:
- Query (Type 1): Formatted as , which means output in sequence. It is guaranteed that .
- Move (Type 2): Formatted as , which means move to the position right after . It is guaranteed that .
- Cut and Reverse (Type 3): Formatted as , which means cut the subsequence , reverse it, and append it to the end of the original sequence. It is guaranteed that .
- Modify (Type 4): Formatted as , which means update to (i.e., ). It is guaranteed that and .
Input Format
- The first line contains two integers and , representing the length of the sequence and the number of queries respectively;
- The second line contains integers ;
- Lines to each contain one query.
Output Format
For each Query (Type 1) operation, output a line containing integers separated by spaces.
In particular, after all operations on the sequence are completed, output a line containing integers, with the specific format shown below:
Final sequence: a[1] a[2] ... a[n]
Samples
Download the sample files from the link below.
Attachments
Download the files here.
Data Range
The information for each test case is shown in the table below (this problem does not use bundled testing):
| Test Case ID | Belongs to Subtask | Special Properties | |
|---|---|---|---|
- Special Property : The data is random.
- Special Property : Only Query (Type 1) and Modify (Type 4) operations are present.
- Special Property : Only Move (Type 2) operations are present.
- Special Property : Only Cut and Reverse (Type 3) operations are present.
- Special Property : No special properties.
For of the data, and .