#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<=n; i++){
for(j=1; j<=n; j++){
if(v[i]==v[j]){
mp[{v[i], j}]=mp[{v[i], j-1}]+1;
}
else {
mp[{v[i], j}]=mp[{v[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 |
3083 ms |
3660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3057 ms |
9060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3088 ms |
15980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3073 ms |
64448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3082 ms |
171164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3091 ms |
130432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3089 ms |
205788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3064 ms |
175248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3065 ms |
258192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
253528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |