#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define pii pair<int, int>
#define piii pair<pii, int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define f first
#define s second
#define oo 1000000001
#define eb emplace_back
#define pb push_back
#define mpr make_pair
#define size(v) (int)v.size()
#define ln '\n'
#define ull unsigned long long
#define ll long long
#define all(v) v.begin(), v.end()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
int n, k, m;
cin >> n >> k >> m;
vector<int>arr(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
--arr[i];
}
int type, p, v;
while (m--) {
cin >> type;
if (type == 1) {
cin >> p >> v;
--v;
arr[p] = v;
} else {
int ans = oo;
vector<int>cnt(k, 0);
int diff = 0;
int l = 1, r = 1;
while (l <= n) {
while (r <= n && diff < k) {
cnt[arr[r]]++;
if (cnt[arr[r]] == 1) {
++diff;
}
++r;
}
if (diff == k) {
ans = min(ans, r - l);
}
cnt[arr[l]]--;
if (cnt[arr[l]] == 0) {
--diff;
}
++l;
}
if (ans == oo) ans = -1;
cout << ans << ln;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
212 KB |
Output is correct |
2 |
Correct |
13 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
340 KB |
Output is correct |
2 |
Correct |
18 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2068 ms |
676 KB |
Output is correct |
2 |
Execution timed out |
3037 ms |
1180 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3049 ms |
716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3055 ms |
568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3055 ms |
724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |