luogu#P5211. [ZJOI2017] 字符串
[ZJOI2017] 字符串
Background
Pig Xiaoxia has recently been studying string-related theory, and now he has encountered the following problem.
Problem Description
Maintain a dynamic string , whose alphabet is all integers with . You need to support two operations:
-
Input . For all , modify to . Note that may be negative.
-
Input . Output the starting position of the lexicographically smallest suffix of the substring . That is, if the smallest suffix is (), output .
Input Format
The first line contains two non-negative integers .
The next line contains positive integers, representing the initial string.
The next lines each describe an operation in the form or , corresponding to the two operations above.
Output Format
For each query operation, output the answer in order.
5 5
3 2 1 4 3
2 1 5
1 2 4 2
2 1 5
1 2 5 1
2 1 5
3
5
1
Hint
| Test Point ID | Other Constraints | ||
|---|---|---|---|
| None | |||
| Only the second type of operation | |||
| testdata generated randomly | |||
| None | |||
Constraints: For of the data, , , and .
Note: In test points and , during random generation, is chosen randomly from , and is chosen randomly from . The operation type and the operation interval are both selected uniformly at random.
Translated by ChatGPT 5