Submission #766900

#TimeUsernameProblemLanguageResultExecution timeMemory
766900birktjRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <stack> #include <algorithm> #include <iostream> using namespace std; stack<int> box, pile, discard; void fill_box(int x) { while (!pile.empty()) { int i = pile.top(); pile.pop(); moveIntoBox(i); box.push(i); int maxCount = pressButton(); if (maxCount > x) { moveOutOfBox(i); box.pop(); discard.push(i); } } } void empty_box() { while (!box.empty()) { int i = box.top(); box.pop(); moveOutOfBox(i); discard.push(i); } } int solve(int N) { for (int i = 0; i < N; i++) { pile.push(i); } fill_box(1); swap(discard, pile); int k = box.size(); empty_box(); discard = {}; //printCounts(); //cerr << "piles size = " << pile.size() << endl; //cerr << "discard size = " << discard.size() << endl; //cerr << "box size = " << box.size() << endl; int l = 1; int u = N/k; while (l + 1 <= u) { int m = (l + u + 1) / 2; //cerr << "m = " << m << endl; //cerr << "l = " << l << endl; fill_box(m - l); swap(discard, pile); empty_box(); //cerr << "piles size = " << pile.size() << endl; //cerr << "discard size = " << discard.size() << endl; //cerr << "discard size + extra = " << discard.size() + k*l << endl; //printCounts(); if (discard.size() + k*l == m*k) { discard = {}; l = m; } else { pile = {}; swap(discard, pile); u = m-1; } } return l; }

Compilation message (stderr)

insects.cpp: In function 'void fill_box(int)':
insects.cpp:14:9: error: 'moveIntoBox' was not declared in this scope
   14 |         moveIntoBox(i);
      |         ^~~~~~~~~~~
insects.cpp:16:24: error: 'pressButton' was not declared in this scope; did you mean 'press_button'?
   16 |         int maxCount = pressButton();
      |                        ^~~~~~~~~~~
      |                        press_button
insects.cpp:18:13: error: 'moveOutOfBox' was not declared in this scope
   18 |             moveOutOfBox(i);
      |             ^~~~~~~~~~~~
insects.cpp: In function 'void empty_box()':
insects.cpp:29:9: error: 'moveOutOfBox' was not declared in this scope
   29 |         moveOutOfBox(i);
      |         ^~~~~~~~~~~~
insects.cpp: In function 'int solve(int)':
insects.cpp:68:34: warning: comparison of integer expressions of different signedness: 'std::stack<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |         if (discard.size() + k*l == m*k) {
      |             ~~~~~~~~~~~~~~~~~~~~~^~~~~~