Submission #658619

#TimeUsernameProblemLanguageResultExecution timeMemory
658619pere_gilRarest Insects (IOI22_insects)C++17
0 / 100
3056 ms300 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; int min_cardinality(int n) { queue<int> in,out; for(int i=0;i<n;i++){ move_inside(i); if(press_button()>1){ move_outside(i); out.push(i); } else in.push(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; queue<int> new_in,new_out; while(!out.empty()){ int u=out.front(); out.pop(); move_inside(u); int q=press_button(); if(q>med){ move_outside(u); new_out.push(u); } else new_in.push(u); if(in.size()+new_in.size()==dif*med) break; } if(in.size()+new_in.size()==dif*med){ while(!new_in.empty()){ in.push(new_in.front()); new_in.pop(); } while(!new_out.empty()){ out.push(new_out.front()); new_out.pop(); } l=med; } else{ while(!new_in.empty()){ int u=new_in.front(); new_in.pop(); move_outside(u); out.push(u); } r=med-1; } } return l; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:35:30: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |    if(in.size()+new_in.size()==dif*med) break;
      |       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
insects.cpp:38:29: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   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...