#P8415. [THUPC 2022 决赛] pmrmscxip
[THUPC 2022 决赛] pmrmscxip
Problem Description
Given a sequence and a permutation , there are operations in total:
- Modify operation: given , change to .
- Query operation: given , find the longest sub-interval within (i.e., satisfying ) such that for all , we have , and there exists some with . You need to output the maximum possible value of that satisfies the conditions; if no such interval exists, output .
Input Format
The first line contains two integers .
The second line contains integers, representing in order.
The third line contains integers, representing in order.
The next lines each contain either or , indicating one modify operation or one query operation.
All input values are integers.
Output Format
For each query operation, output one line containing the corresponding answer.
8 10
1 4 7 3 8 2 4 7
5 4 8 7 1 6 3 2
2 6 6 2
2 8 8 7
1 4 3
2 6 8 3
2 4 4 3
2 4 4 3
2 6 8 4
2 5 6 2
2 1 8 1
2 1 1 6
1
1
0
1
1
3
2
1
0
Hint
Constraints:
.
.
, and all are distinct.
For modify operations, .
For query operations, , .
Translated by ChatGPT 5