#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 in the samples.
Samples
A large sample for this problem is provided. Please download it from the "Attachments" section.
10 5
1 2 3 4 5 6 7 8 9 10
1 3 8
2 9 10
3 4 7
4 5 114
1 4 6
3 4 5 6 7 8
8 114 9
Final sequence: 1 2 3 8 114 9 7 6 5 4
10 10
9 6 8 6 7 2 4 6 7 10
3 2 5
3 6 10
3 9 10
4 8 328728721
4 7 -662061217
4 3 -247898505
3 3 9
3 7 8
1 8 8
2 5 10
-247898505
Final sequence: 9 2 7 10 -662061217 6 -247898505 7 6 328728721
Attachments
Download the attached files from 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 .