Sequence and Queries 16
InterviewTime limit2sMemory limit512 MB
Maintain an array under point updates and range queries that ask for the leftmost index of the minimum value in a subarray.
- Level
Medium6 of 10
- Topics
- Segment tree, Array, Implementation, Divide and conquer
- Solved
- No attempts yet
Problem
You are given a sequence of length . Write a program that processes the following two kinds of queries.
1 i v: Replace with . (, )2 i j: Print the index of the smallest value among . If several elements share that smallest value, print the smallest index among them. ()
Indices of the sequence start at 1.
Input
The first line contains the length of the sequence . ()
The second line contains . ()
The third line contains the number of queries . ()
Each of the next lines contains one query.
Output
For each query of type 2, print its answer on its own line, in the order the queries are given.