Submission #629049

#TimeUsernameProblemLanguageResultExecution timeMemory
629049two_sidesRarest Insects (IOI22_insects)C++17
53.16 / 100
178 ms444 KiB
#include "insects.h" #include <bits/stdc++.h> namespace { using namespace std; set<int> inside; void insert(int i) { inside.insert(i); move_inside(i); } void erase(int i) { inside.erase(i); move_outside(i); } } int min_cardinality(int n) { for (int i = 0; i < n; i++) { insert(i); if (press_button() > 1) erase(i); } int t = inside.size(); int l = 1, r = n / t; while (l < r) { int m = (l + r + 1) / 2; vector<int> last; for (int i = 0; i < n; i++) if (!inside.count(i)) { insert(i); if (press_button() > m) erase(i); else { last.push_back(i); if (inside.size() == m * t) break; } } if (inside.size() == m * t) l = m; else { for (int i : last) erase(i); r = m - 1; } } return r; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:37:39: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |                     if (inside.size() == m * t) break;
      |                         ~~~~~~~~~~~~~~^~~~~~~~
insects.cpp:40:27: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |         if (inside.size() == m * t) l = m;
      |             ~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...