배열에서 값을 바꾸는 갱신과 함께, 각 질의 l에 대해 l <= a < b < c < d이고 x_a < x_b < x_c < x_d인 가장 작은 d를 구하거나 없으면 -1을 출력한다.
어려움9세그먼트 트리동적 계획법이분 탐색구현아직 제출이 없습니다시간 제한5초메모리 제한512 MBYou may be right that there are a lot (maybe even too many) problems of kind ``given array of length 105 and 105 queries of 105 different types, do some...
- Um_nik
You are given an array x_1,x_2,…,x_n.
You need to perform two types of queries on this array.
The first line contains two integers n,q (1≤n,q≤500,000): the number of elements in the array and the number of queries.
The second line contains n integers x_1,x_2,…,x_n (1≤x_i≤109).
Each of the next q lines contains the description of a query.
If the first integer in the line is equal to 1, then the next two integers are i and y (1≤i≤n, 1≤y≤109), describing a query of the first type.
Otherwise, the first integer in the line is equal to 2, and the next integer is equal to l (1≤l≤n), describing a query of the second type.
For each query of the second type, return the smallest d among all tuples (a,b,c,d) such that l≤a<b<c<d and x_a<x_b<x_c<x_d, or print "-1" if there are no such tuples.