Submission #658620

#TimeUsernameProblemLanguageResultExecution timeMemory
658620pere_gilRarest Insects (IOI22_insects)C++17
0 / 100
3075 ms208 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; int min_cardinality(int n) { vector<int> in,out; for(int i=0;i<n;i++){ move_inside(i); if(press_button()>1){ move_outside(i); out.push_back(i); } else in.push_back(i); } int dif=(int)in.size(); if(dif==1) return n; int l=1,r=n/dif+1; while(l<r){ int med=(l+r)/2; vector<int> new_in,new_out; while(out.size()){ int u=out[out.size()-1]; out.pop_back(); move_inside(u); int q=press_button(); if(q>med){ move_outside(u); new_out.push_back(u); } else new_in.push_back(u); if(in.size()+new_in.size()==dif*med) break; } if(in.size()+new_in.size()==dif*med){ for(int i: new_in) in.push_back(i); for(int i: new_out) out.push_back(i); l=med; } else{ for(int i: new_in){ move_outside(i); out.push_back(i); } r=med-1; } } return l; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:36:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |    if(in.size()+new_in.size()==dif*med) break;
      |       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
insects.cpp:39:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |   if(in.size()+new_in.size()==dif*med){
      |      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...