#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=0, cavab=n+100;
while(r<=n){
bool f=true;
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 |
3002 ms |
3540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3093 ms |
8912 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3074 ms |
16000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3101 ms |
64452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3098 ms |
171332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3060 ms |
130324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3084 ms |
205648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3102 ms |
190292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3109 ms |
314200 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3110 ms |
314124 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |