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>
#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);
if (ans == k) break;
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 |
---|
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... |