제출 #677349

#제출 시각아이디문제언어결과실행 시간메모리
677349Ninja_Kunai드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
/**
*    Author :  Nguyen Tuan Vu
*    Created : 03.01.2023
**/

#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define MASK(x) ((1ll)<<(x))
#define BIT(x, i) (((x)>>(i))&(1))
#define ALL(v)  (v).begin(), (v).end()
#define REP(i, n)  for (int i = 0, _n = (n); i < _n; ++i)
#define FOR(i, a, b)  for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a)  for (int i = (b), _a = (a); i >= _a; --i)
#define db(val) "["#val" = "<<(val)<<"] "

template <class X, class Y> bool minimize(X &a, Y b) {
    if (a > b) return a = b, true;
    return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
    if (a < b) return a = b, true;
    return false;
}

using namespace std;

mt19937 jdg(chrono::steady_clock::now().time_since_epoch().count());
int Rand(int l, int r) {return l + jdg() % (r - l + 1);}

const int N = 2e3 + 5;
set <int> machine;

long long min_cardinality(int n) {
    FOR(i, 1, n) {
        move_inside(i);

        if (press_button() > 1) move_outside(i);
        else machine.insert(i);
    }

    int distinct = machine.size();
    int sign = 0;
    int l = 0, r = n / machine.size() + 1;
    while (r - l > 1) {
        int mid = (l + r) >> 1;

        if (sign == 0) {
            FOR(i, 1, n) if (machine.find(i) == machine.end()) {
                move_inside(i);

                if (press_button() > mid) {
                    move_outside(i);
                }
                else {
                    machine.insert(i);
                }
            }

            if (machine.size() == distinct * mid) l = mid;
            else {
                sign = 1;
            }
        }
        else {
            set <int> cur = machine;
            for (auto x : machine) {
                move_outside(x);
            }

            machine.clear();
            for (auto x : cur) {
                move_inside(x);

                if (press_button() > mid) move_outside(x);
                else machine.insert(x);
            }

            if (machine.size() == distinct * mid) sign = 0, l = mid;
            else {
                sign = 1;
            }
        }
    }

    cout << l;
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'long long int min_cardinality(int)':
insects.cpp:36:9: error: 'move_inside' was not declared in this scope
   36 |         move_inside(i);
      |         ^~~~~~~~~~~
insects.cpp:38:13: error: 'press_button' was not declared in this scope
   38 |         if (press_button() > 1) move_outside(i);
      |             ^~~~~~~~~~~~
insects.cpp:38:33: error: 'move_outside' was not declared in this scope
   38 |         if (press_button() > 1) move_outside(i);
      |                                 ^~~~~~~~~~~~
insects.cpp:50:17: error: 'move_inside' was not declared in this scope
   50 |                 move_inside(i);
      |                 ^~~~~~~~~~~
insects.cpp:52:21: error: 'press_button' was not declared in this scope
   52 |                 if (press_button() > mid) {
      |                     ^~~~~~~~~~~~
insects.cpp:53:21: error: 'move_outside' was not declared in this scope
   53 |                     move_outside(i);
      |                     ^~~~~~~~~~~~
insects.cpp:60:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |             if (machine.size() == distinct * mid) l = mid;
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
insects.cpp:68:17: error: 'move_outside' was not declared in this scope
   68 |                 move_outside(x);
      |                 ^~~~~~~~~~~~
insects.cpp:73:17: error: 'move_inside' was not declared in this scope
   73 |                 move_inside(x);
      |                 ^~~~~~~~~~~
insects.cpp:75:21: error: 'press_button' was not declared in this scope
   75 |                 if (press_button() > mid) move_outside(x);
      |                     ^~~~~~~~~~~~
insects.cpp:75:43: error: 'move_outside' was not declared in this scope
   75 |                 if (press_button() > mid) move_outside(x);
      |                                           ^~~~~~~~~~~~
insects.cpp:79:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |             if (machine.size() == distinct * mid) sign = 0, l = mid;
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~