답안 #886579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886579 2023-12-12T10:38:39 Z thinknoexit 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
mt19937 rnd(time(0));
int n;
int sz = 0;
bool mark[2020];
void putin(int x) {
    move_inside(x);
    sz++;
}
void putout(int x) {
    move_outside(x);
    sz--;
}
int val() {
    return press_button();
}
int min_cardinality(int N) {
    n = N;
    vector<int> a(n);
    for (int i = 0;i < n;i++) a[i] = i;
    shuffle(a.begin(), a.end(), rnd());
    putin(a[0]);
    mark[a[0]] = 1;
    for (int i = 1;i < n;i++) {
        putin(a[i]);
        if (val() == 2) {
            putout(a[i]);
        }
        else {
            mark[a[i]] = 1;
        }
    }
    int type = sz;
    if (type == n) return 1;
    int l = 1, r = n / sz;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        stack<int> st, st2;
        for (int i = 0;i < n;i++) {
            if (sz == type * mid) break;
            if (mark[a[i]]) continue;
            putin(a[i]);
            if (val() > mid) {
                putout(a[i]);
                mark[a[i]] = 1;
                st2.push(a[i]);
            }
            else {
                st.push(a[i]);
            }
        }
        if (sz == type * mid) {
            while (!st.empty()) {
                mark[st.top()] ^= 1;
                st.pop();
            }
            while (!st2.empty()) {
                mark[st2.top()] ^= 1;
                st2.pop();
            }
            l = mid;
        }
        else {
            if (l == mid - 1) return l;
            while (!st.empty()) {
                putout(st.top());
                st.pop();
            }
            r = mid - 1;
        }
    }
    return l;
}

Compilation message

In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from insects.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = long unsigned int]':
insects.cpp:24:38:   required from here
/usr/include/c++/10/bits/stl_algo.h:3769:2: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type
 3769 |  __uc_type;
      |  ^~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type
 3797 |    const pair<__uc_type, __uc_type> __pospos =
      |                                     ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type