Submission #555669

# Submission time Handle Problem Language Result Execution time Memory
555669 2022-05-01T10:25:02 Z BT21tata Nekameleoni (COCI15_nekameleoni) C++17
0 / 140
3000 ms 1112 KB
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
#pragma GCC target ("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define setp fixed<<setprecision
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
const ll mod=(1ll<<31)-1;
const ld eps=1e-8;
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
 
int n, Q, k, a[100005], cnt[55];
 
int main()
{
    SPEED;
    cin>>n>>k>>Q;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    while(Q--)
    {
        int q, p, v;
        cin>>q;
        if(q==1)
        {
            cin>>p>>v;
            a[p]=v;
        }
        else
        {
            int l=1, r=1, num=0, ans=n;
            memset(cnt, 0, sizeof(cnt));
            while(r<=n)
            {
                cnt[a[r]]++;
                if(cnt[a[r]]==1) num++;
                while(cnt[a[l]]>1)
                {
                    cnt[a[l]]--;
                    l++;
                }
                if(num==k) ans=min(ans, r-l+1);
                r++;
            }
            cout<<((ans==MOD)? -1 : ans)<<endl;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 35 ms 340 KB Output is correct
2 Incorrect 5 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 368 KB Output is correct
2 Incorrect 11 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 396 KB Output is correct
2 Incorrect 14 ms 420 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2511 ms 808 KB Output is correct
2 Execution timed out 3055 ms 1112 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3086 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3077 ms 928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3077 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3042 ms 1044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 712 KB Time limit exceeded
2 Halted 0 ms 0 KB -