답안 #555650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
555650 2022-05-01T10:00:49 Z computerbox Nekameleoni (COCI15_nekameleoni) C++14
42 / 140
3000 ms 960 KB
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 400010

using namespace std;

struct segment{
  int cntpref[51], cntsuf[51], cntres[51];
};

segment t[4 * 100010];

int massiv[100010];

int next[100010];
int n, k , m;

int main(){
FAST_READ;
cin.tie(0);
cout.tie(0);
cin >> n >> k >> m;
for(int i = 1; i <= n; i++)
{
  cin >> massiv[i];
}

while(m--)
{
  int t;
  cin >> t;
  if(t == 2)
  {
    int ans = INT_MAX;
    deque<int>el;
    vector<int>cntt;
    cntt.resize(51);
    int cntres = 0;
    int r = 1;
    for(int i = 1; i <= n; i++)
    {
      while(r <= n && cntres < k)
      {
        if(cntt[massiv[r]] == 0){cntres++;}
        cntt[massiv[r]]++;
        el.push_back(massiv[r]);
        r++;
      }
      if(cntres == k)
      {
        ans = min(ans, (int)el.size());
      }
      cntt[el.front()]--;
      if(cntt[el.front()] == 0)
      {
        cntres--;
      }
      el.pop_front();
    }
    cout << (ans == INT_MAX ? -1 : ans) << endl;
  }
  else
  {
    int x, y;
    cin >> x >> y;
    massiv[x] = y;
  }
}



return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 340 KB Output is correct
2 Correct 14 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 372 KB Output is correct
2 Correct 19 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 468 KB Output is correct
2 Correct 31 ms 412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3075 ms 820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3066 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3061 ms 744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3074 ms 912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3076 ms 696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3077 ms 940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 960 KB Time limit exceeded
2 Halted 0 ms 0 KB -