Submission #822933

#TimeUsernameProblemLanguageResultExecution timeMemory
822933finn__드문 곤충 (IOI22_insects)C++17
47.77 / 100
194 ms528 KiB
#include <bits/stdc++.h> #include "insects.h" std::bitset<2000> in_machine; int min_cardinality(int N) { move_inside(0); in_machine[0] = 1; int d = 1; for (int i = 1; i < N; ++i) { move_inside(i); if (press_button() > 1) move_outside(i); else ++d, in_machine[i] = 1; } for (int i = 0; i < N; ++i) if (in_machine[i]) move_outside(i), in_machine[i] = 0; int a = 1, b = N; while (a < b) { int const mid = (a + b + 1) >> 1; std::vector<int> moved; for (int i = 0; i < N && in_machine.count() < d * mid; ++i) if (!in_machine[i]) { move_inside(i); if (press_button() > mid) move_outside(i); else in_machine[i] = 1, moved.push_back(i); } if (in_machine.count() == d * mid) { a = mid; } else { b = mid - 1; for (auto const &i : moved) in_machine[i] = 0, move_outside(i); } } return a; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:30:53: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |         for (int i = 0; i < N && in_machine.count() < d * mid; ++i)
      |                                  ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
insects.cpp:40:32: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |         if (in_machine.count() == d * mid)
      |             ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...