Submission #555618

#TimeUsernameProblemLanguageResultExecution timeMemory
555618FidanNekameleoni (COCI15_nekameleoni)C++17
42 / 140
3091 ms41940 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MAXN=400010; const ll inf=(1e18); 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); vector<vector<ll>> dp(k+1, vector<ll> (n+1, 0)); 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]){ dp[i][j]=dp[i][j-1]+1; } else { dp[i][j]=dp[i][j-1]; } } } while(m--){ ll test; cin>>test; if(test==1){ ll p, val; cin>>p>>val; for(i=p; i<=n; i++){ dp[v[p]][i]--; } v[p]=val; for(i=p; i<=n; i++){ dp[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(dp[i][r]-dp[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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...