# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
469314 | ala2 | Nekameleoni (COCI15_nekameleoni) | C++14 | 3088 ms | 1864 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |