Submission #629368

#TimeUsernameProblemLanguageResultExecution timeMemory
629368dacin21Rarest Insects (IOI22_insects)C++17
100 / 100
67 ms464 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*(all.size()%B) >= B))/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:43:48: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   43 |         const int t = (l+r+1+(2*(all.size()%B) >= B))/2;
      |                               ~~~~~~~~~~~~~~~~~^~~~
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...