#P7230. [COCI 2015/2016 #3] NEKAMELEONI
[COCI 2015/2016 #3] NEKAMELEONI
Background
“Hey, dear! I’m going to create Task 5 for the Croatian Open Competition In Informatics on November .”
“Go ahead, go ahead…”
“…”
“How about this problem?”
“Um… this is too hard… it will stump those cuties. Make it easier…”
So the lovely problem setter made this problem.
Hey! I have an solution. What is the range of ??
Problem Description
You are given an array with elements. You need to process queries.
- The first type of query asks you to change the -th number in the array to .
- The second type of query asks you to determine the length of the shortest contiguous subarray in the current array that contains all numbers from to .
Input Format
The first line contains three positive integers .
The second line contains positive integers separated by spaces, representing the numbers in the array.
Then follow lines describing queries. Each query has one of the following two forms.
- : change the -th number in the array to .
- : determine and output the length of the shortest contiguous subarray in the current array that contains all numbers from to .
Output Format
Only query produces output.
For each query , output the length of the shortest contiguous subarray in the current array (which must contain all numbers from to ). If no such subarray exists, output .
4 3 5
2 3 1 2
2
1 3 3
2
1 1 1
2
3
-1
4
6 3 6
1 2 3 2 1 1
2
1 2 1
2
1 4 1
1 6 2
2
3
3
4
Hint
Constraints and Conventions
- For of the testdata, .
- For of the testdata, , , , .
Notes
Translated from COCI 2015-2016 #3 E NEKAMELEONI, full score 140.
Translated by ChatGPT 5