Submission #557251

# Submission time Handle Problem Language Result Execution time Memory
557251 2022-05-05T04:49:20 Z pokmui9909 Nekameleoni (COCI15_nekameleoni) C++17
56 / 140
3000 ms 2012 KB
#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
1 Correct 24 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 408 KB Output is correct
2 Correct 7 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 408 KB Output is correct
2 Correct 9 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1738 ms 980 KB Output is correct
2 Correct 1896 ms 2012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 1292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 1336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 1300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3066 ms 1708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 1596 KB Time limit exceeded
2 Halted 0 ms 0 KB -