Submission #469314

#TimeUsernameProblemLanguageResultExecution timeMemory
469314ala2Nekameleoni (COCI15_nekameleoni)C++14
56 / 140
3088 ms1864 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int a[1001000]; int v[100]; signed main() { int n,m,k; cin>>n>>k>>m; for(int i=1-1;i<=n-1;i++) cin>>a[i]; int mn=1e9; for(int vv=0;vv<m;vv++) { int x; cin>>x; if(x==1) { int y,z; cin>>y>>z; a[y-1]=z; } else { for(int i=0;i<k+1;i++) v[i]=0; // for(int i=0;i<n;i++) cout<<a[i]<<" "; mn=1e9; int g=0; int j=3e9; for(int i=0;i<n;i++) { if(!v[a[i]]) g++; v[a[i]]++; if(g==k){ j=i; break; } } mn=min(mn,j+1); // cout<<" : "<<mn<<endl; if(mn>n) { cout<<-1<<endl; continue; } int i=0; while(i<n&&j<n&&i<=j) { //cout<<" "<<mn; i++; v[a[i-1]]--; if(v[a[i-1]]>0) { // v[a[i]]--; mn=min(mn,j-i+1); // cout<<" :" <<mn<<" "<<i<<" "<<j<< endl; } else { j++; while(a[j]!=a[i-1]&&j<n-1) { v[a[j]]++; j++; } v[a[j]]++; if(a[j]==a[i-1]){ // cout<<mn<<" "; mn=min(mn,j-i+1); // cout<< " "<<mn<<endl; // cout<<" "<<i<<" "<<j<<" "<<mn<<endl; } else { // cout<<" : : "<<i<<endl; break; } } } cout<<mn<<endl; } } }

Compilation message (stderr)

nekameleoni.cpp: In function 'int main()':
nekameleoni.cpp:33:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |                 if(!v[a[i]])
      |                 ^~
nekameleoni.cpp:35:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |                     v[a[i]]++;
      |                     ^
#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...