Submission #629367

#TimeUsernameProblemLanguageResultExecution timeMemory
629367dacin21Rarest Insects (IOI22_insects)C++17
99.89 / 100
71 ms444 KiB
#include "insects.h" /* void move_inside(int i); void move_outside(int i); int press_button(); */ #include <bits/stdc++.h> using namespace std; vector<int> in, out; void one_pass(vector<int> pool, int tr){ in.clear(); out.clear(); for(auto &e : pool){ move_inside(e); if(press_button() > tr){ move_outside(e); out.push_back(e); } else { in.push_back(e); } } for(auto &e : in){ move_outside(e); } } int min_cardinality(int n) { vector<int> all(n); iota(all.begin(), all.end(), 0); one_pass(all, 1); const int B = in.size(); int ans = 1; all = out; while(all.size() >= B){ const int l = 0, r = all.size()/B; // const int t = (all.size() / B + 1) / 2; const int t = (l+r+1)/2; one_pass(all, t); if(in.size() == t*B){ ans += t; all = out; } else { all = in; } } return ans; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   40 |     while(all.size() >= B){
      |           ~~~~~~~~~~~^~~~
insects.cpp:45:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if(in.size() == t*B){
      |            ~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...