Submission #1261169

#TimeUsernameProblemLanguageResultExecution timeMemory
1261169xtl드문 곤충 (IOI22_insects)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> inside;
unordered_set<int> sett;
int min_cardinality(int N)
{
    // number of different types
    for (int i = 0; i < N; i++)
    {
        move_inside(i);
        if (press_button() > 1)
        {
            move_outside(i);
            sett.insert(i);
        }
        else
            inside.push_back(i);
    }
    int l = 1;
    int r = N / inside.size();
    // binary search
    while (l < r)
    {
        int m = l + (r - l + 1) / 2;
        vector<int> w;
        vector<int> outs;
        for (int i : sett)
        {
            move_inside(i);
            if (press_button() > m)
            {
                move_outside(i);
                outs.push_back(i);
            }
            else
                w.push_back(i);
        }
        if (w.size() == inside.size() * (m - l))
        {
            l = m;
            for (int i : w)
                sett.erase(i);
        }
        else
        {
            for (int i : outs)
                sett.erase(i);
            for (int i : w)
                move_outside(i);
            r = m - 1;
        }
    }
    return l;
}

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:10:9: error: 'move_inside' was not declared in this scope
   10 |         move_inside(i);
      |         ^~~~~~~~~~~
insects.cpp:11:13: error: 'press_button' was not declared in this scope
   11 |         if (press_button() > 1)
      |             ^~~~~~~~~~~~
insects.cpp:13:13: error: 'move_outside' was not declared in this scope
   13 |             move_outside(i);
      |             ^~~~~~~~~~~~
insects.cpp:29:13: error: 'move_inside' was not declared in this scope
   29 |             move_inside(i);
      |             ^~~~~~~~~~~
insects.cpp:30:17: error: 'press_button' was not declared in this scope
   30 |             if (press_button() > m)
      |                 ^~~~~~~~~~~~
insects.cpp:32:17: error: 'move_outside' was not declared in this scope
   32 |                 move_outside(i);
      |                 ^~~~~~~~~~~~
insects.cpp:49:17: error: 'move_outside' was not declared in this scope
   49 |                 move_outside(i);
      |                 ^~~~~~~~~~~~