#include<bits/stdc++.h>
using namespace std;
const int MAXN = 50010;
const int MAXK = 50;
int k;
vector<int> pref[50];
bool check(int l, int r) {
bool c = true;
for(int i = 0;i<k;i++) {
if(!(pref[i][r+1] - pref[i][l]))c = false;
}
return c;
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> k >> m;
for(int i = 0;i<50;i++) {
pref[i].resize(MAXN);
}
int arr[n];
for(int i = 0;i<n;i++){
cin >> arr[i];
arr[i]--;
}
for(int i = 0;i<50;i++) {
pref[i][0] = 0;
for(int j = 1;j<=n;j++) {
if(arr[j-1] == i) {
pref[i][j] = pref[i][j-1]+1;
}
else pref[i][j] = pref[i][j-1];
}
}
while(m--) {
int type;
cin >> type;
if(type == 1) {
int p, v;
cin >> p >> v;
v--;p--;
arr[p] = v;
for(int i = 0;i<50;i++) {
pref[i][0] = 0;
for(int j = 1;j<=n;j++) {
if(arr[j-1] == i) {
pref[i][j] = pref[i][j-1]+1;
}
else pref[i][j] = pref[i][j-1];
}
}
}
else {
int p1 = 0, p2 = 0;
int ans = 1e9;
while(p2 < n) {
if(check(p1, p2)) {
ans = min(ans, (int)p2-p1+1);
p1++;
}
else {
p2++;
}
}
if(ans == 1e9)ans = -1;
cout << ans << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1110 ms |
10192 KB |
Output is correct |
2 |
Correct |
1166 ms |
10144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3097 ms |
10144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3058 ms |
10148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3066 ms |
10196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
20752 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3047 ms |
10196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
20836 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
20820 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
21168 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
21156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |