#P7230. Shortest Subarray Covering a Range Query
Shortest Subarray Covering a Range Query
Shortest Subarray Covering a Range Query
You are given an array of n integers and you need to process q queries. The queries are of two types:
- Type 1: Update the array by setting the element at position p to v.
- Type 2: Determine the length of the shortest contiguous subarray that contains all integers from 1 to k. If no such subarray exists, output -1.
Note: The array is 1-indexed.
All mathematical formulas must be in LaTeX format. For example, the range of elements is given by $1\leq p\leq n$ and the complete set of numbers required in a subarray is $\{1,2,...,k\}$.
inputFormat
The first line contains three integers n, q, and k.
The second line contains n integers representing the array.
Each of the following q lines represents a query. A query of type 1 is in the format:
1 p v
and a query of type 2 is in the format:
2
outputFormat
For each query of type 2, output a single line containing the length of the shortest contiguous subarray that covers all integers from $1$ to $k$. If no such subarray exists, output -1.
sample
5 3 3
1 2 3 2 1
2
1 5 3
2
3
3
</p>