#P10151. [Ynoi1999] SMV CC-64“蝰蛇”
[Ynoi1999] SMV CC-64“蝰蛇”
Background

Problem Description
Given a sequence and a permutation , there are operations in total:
- Update operation: given , change to .
- Query operation: given , find the longest subsegment 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 subsegment exists, output .
Input Format
The first line contains two integers .
The second line contains integers representing .
The third line contains integers representing .
The next lines each contain either or , indicating an update operation or a 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
Idea: s_r_f, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
Constraints for of the testdata:
.
.
, and all are pairwise distinct.
For update operations, .
For query operations, , .
Translated by ChatGPT 5