답안 #886557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886557 2023-12-12T10:21:30 Z thinknoexit 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
int n;
int sz = 0;
set<int> rem;
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;
    putin(0);
    for (int i = 1;i < n;i++) {
        putin(i);
        if (val() == 2) {
            putout(i);
            rem.insert(i);
        }
    }
    int type = sz;
    if (type == n) return 1;
    int l = 1, r = n / type;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        set<int> in;
        stack<int> st;
        for (auto& x : rem) {
            putin(x);
            in.insert(x);
            st.push(x);
            if (sz > type * mid) {
                while (!st.empty()) {
                    putout(st.top());
                    in.erase(st.top());
                    st.pop();
                    if (val() <= mid) break;
                }
            }
        }
        if (sz == type * mid) {
            for (auto& x : in) {
                rem.erase(x);
            }
            l = mid;
        }
        else {
            for (auto& x : in) {
                putout(x);
            }
            r = mid - 1;
        }
    }
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:62:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |     return ans;
      |            ^~~
      |            abs