#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 |
1 |
Correct |
25 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
356 KB |
Output is correct |
2 |
Correct |
9 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
468 KB |
Output is correct |
2 |
Correct |
12 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1732 ms |
520 KB |
Output is correct |
2 |
Correct |
2968 ms |
996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3091 ms |
740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3047 ms |
648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3073 ms |
832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3048 ms |
800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3092 ms |
1092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3090 ms |
1088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |