#P5692. [MtOI2019] 手牵手走向明天
[MtOI2019] 手牵手走向明天
Description
Rinne gives you a sequence . You need to perform operations in order.
There are two types of operations:
-
Given , change all numbers equal to among into .
-
Given , find such that and , and require to be minimized. Output this minimum value. If there is no solution, output .
Input Format
The first line contains two positive integers , representing the sequence length and the number of operations.
The second line contains positive integers .
The next lines each contain five positive integers . If , it is a modification operation. If , it is a query operation. The meanings of are as described in the statement.
Output Format
For each operation with , output one line with one integer, representing the answer.
6 5
1 1 4 5 1 4
1 1 3 1 7
2 1 4 7 7
1 1 5 7 3
2 2 6 1 3
2 3 3 3 3
0
3
-1
Hint
For of the testdata, , .
This problem has subtasks, with the following limits:
Subtask ( point): Guaranteed that for any operation, .
Subtask ( points): .
Subtask ( points): .
Subtask ( points): Guaranteed that .
Subtask ( points): Guaranteed that when , .
Subtask ( points): No special restrictions.
Time limit:
Memory limit:
Idea: nzhtl1477, mrsrz.
Solution: mrsrz, nzhtl1477.
Code: mrsrz.
Data: mrsrz.
Background: disangan233, mrsrz.
Translated by ChatGPT 5
京公网安备 11011102002149号