Submission #1078170

#TimeUsernameProblemLanguageResultExecution timeMemory
1078170Muhammad_AneeqRarest Insects (IOI22_insects)C++17
92.99 / 100
64 ms852 KiB
void move_inside(int i); void move_outside(int i); int press_button(); #include <iostream> #include <vector> #include <map> #include <set> using namespace std; set<int>ind; int min_cardinality(int N) { int colors=0; for (int i=0;i<N;i++) { move_inside(i); ind.insert(i); if (press_button()==2) { move_outside(i); ind.erase(i); } else colors++; } set<int>ni; for (int i=0;i<N;i++) if (ind.find(i)==ind.end()) ni.insert(i); if (colors==1) return N; int st=1,en=N/colors+1; while (st+1<en) { int mid=(st+en)/2; for (auto i:ni) { if (ind.size()==colors*mid) break; move_inside(i); ind.insert(i); if (press_button()>mid) { move_outside(i); ind.erase(i); } } if (ind.size()==mid*colors) { for (auto i:ind) ni.erase(i); st=mid; } else { en=mid; ni.clear(); for (auto i:ind) { ni.insert(i); move_outside(i); } ind.clear(); } } return st; }

Compilation message (stderr)

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