Submission #555565

# Submission time Handle Problem Language Result Execution time Memory
555565 2022-05-01T07:54:47 Z snasibov05 Nekameleoni (COCI15_nekameleoni) C++14
56 / 140
3000 ms 1616 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n, k, m; cin >> n >> k >> m;
    vector<int> a(n+1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
 
    for (int i = 0; i < m; ++i){
        int t; cin >> t;
        if (t == 1) {
            int p, v; cin >> p >> v;
            a[p] = v;
        } else{
            int ans = n + 1;
            vector<int> ncnt(k+1);
            int cnt = 0;
            int r = 1;
            for (int l = 1; l <= n; ++l){
                while (cnt < k && r <= n) {
                    ncnt[a[r]]++;
                    if (ncnt[a[r]] == 1) cnt++;
                    r++;
                }
                if (cnt < k) break;
                ans = min(ans, r - l);
                ncnt[a[l]]--;
                if (ncnt[a[l]] == 0) cnt--;
            }
            if (ans == n+1) ans = -1;
            cout << ans << "\n";
        }
    }
 
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 332 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 212 KB Output is correct
2 Correct 7 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 340 KB Output is correct
2 Correct 10 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1932 ms 528 KB Output is correct
2 Correct 1909 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3031 ms 812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3031 ms 808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3039 ms 872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 712 KB Time limit exceeded
2 Halted 0 ms 0 KB -