#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=400010;
const ll inf=(1e18);
map<pair<ll, ll>, ll> mp;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, k, m, i, j;
cin>>n>>k>>m;
vector<ll> v(n+1, k+10);
for(ll i=1; i<=n; i++){
cin>>v[i];
}
for(i=1; i<=k; i++){
for(j=1; j<=n; j++){
if(i==v[j]){
mp[{i, j}]=mp[{i, j-1}]+1;
}
else {
mp[{i, j}]=mp[{i, j-1}];
}
}
}
while(m--){
ll test;
cin>>test;
if(test==1){
ll p, val;
cin>>p>>val;
for(i=p; i<=n; i++){
mp[{v[p], i}]--;
}
v[p]=val;
for(i=p; i<=n; i++){
mp[{v[p], i}]++;
}
}
else {
ll l=0, r=k, cavab=n+100;
while(r<=n){
bool f=true;
if(r-l<k){
r++;
continue;
}
for(ll i=1; i<=k; i++){
if(mp[{i, r}]-mp[{i, l}]==0){
f=false;
}
}
if(f){
cavab=min(cavab, r-l);
l++;
}
else {
r++;
}
}
if(cavab==n+100){
cout<<-1<<endl;
}
else {
cout<<cavab<<endl;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3091 ms |
3532 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3079 ms |
8892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
15996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
64448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
171204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
130272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3064 ms |
205696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3072 ms |
190236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
314104 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3083 ms |
314476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |