This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K, M;
ll A[100005];
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N >> K >> M;
for(ll i = 1; i <= N; i++){
cin >> A[i];
}
while(M--){
ll op; cin >> op;
if(op == 1){
ll x, y; cin >> x >> y;
A[x] = y;
} else {
ll ans = 1e18;
vector<ll> V(K + 1);
ll L = 1, R = 1, E = K;
V[A[1]]++, E--;
while(L <= R && R <= N){
if(E == 0){
ans = min(ans, R - L + 1);
V[A[L]]--;
if(V[A[L]] == 0) E++;
L++;
} else {
R++;
if(R > N) break;
if(V[A[R]] == 0) E--;
V[A[R]]++;
}
}
cout << (ans == 1e18 ? -1 : ans) << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |