Submission #736906

#TimeUsernameProblemLanguageResultExecution timeMemory
736906onlk97Rarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { mt19937 mt(time(nullptr)); vector <int> v; for (int i=0; i<N; i++) v.push_back(i); shuffle(v.begin(),v.end(),mt); int cnt=0; set <int> s; for (int i=0; i<N; i++){ move_inside(v[i]); s.insert(v[i]); int tp=press_button(); if (tp>1){ move_outside(v[i]); s.erase(v[i]); } } for (int i:s) move_outside(i); int l=1,r=N; while (l<r){ int mid=(l+r+1)/2; for (int i=0; i<N; i++){ move_inside(v[i]); s.insert(v[i]); int tp=(i+1>=mid?press_button():0); if (tp>mid){ move_outside(v[i]); s.erase(v[i]); } } if (s.size()==mid*cnt) l=mid; else r=mid-1; } return l; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:34:21: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if (s.size()==mid*cnt) l=mid;
      |             ~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...