Submission #557251

#TimeUsernameProblemLanguageResultExecution timeMemory
557251pokmui9909Nekameleoni (COCI15_nekameleoni)C++17
56 / 140
3084 ms2012 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...