Submission #560121

# Submission time Handle Problem Language Result Execution time Memory
560121 2022-05-11T05:20:23 Z proma Nekameleoni (COCI15_nekameleoni) C++17
42 / 140
3000 ms 2072 KB
#include <bits/stdc++.h>

#define int long long
#define see(x) cout<<#x<<"="<<x<<"\n";
#define endl "\n"

using namespace std;

const int N = 2*1e5+5;
const int INF = 1e18;

int n, k, m, a[N];
int used, cnt[55];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
/*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/

    cin >> n >> k >> m;

    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
    }

    while (m --) {
        int t;
        cin >> t;
        if (t == 1) {
            int p, v;
            cin >> p >> v;
            a[p] = v;
        }
        else {
            memset(cnt, 0, sizeof(cnt));
            used = 1;
            cnt[a[1]] = 1;
            int ans = INF;
            for (int l = 1, r = 1; r <= n;) {
                if (used == k) ans = min(ans, r - l + 1);
                r ++;
                cnt[a[r]] ++;
                if (cnt[a[r]] == 1) used ++;
                while (cnt[a[l]] > 1) {
                    cnt[a[l]] --;
                    l ++;
                }
            }
            if (ans == INF) ans = -1;
            cout << ans << endl;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 26 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 344 KB Output is correct
2 Correct 11 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 404 KB Output is correct
2 Correct 14 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1708 ms 892 KB Output is correct
2 Execution timed out 3065 ms 2072 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 1372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3066 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3036 ms 1332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 1420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3066 ms 1596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 1744 KB Time limit exceeded
2 Halted 0 ms 0 KB -