Submission #742656

#TimeUsernameProblemLanguageResultExecution timeMemory
742656dooweyRarest Insects (IOI22_insects)C++17
90.24 / 100
128 ms468 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair int min_cardinality(int n) { int val; set<int> in; set<int> cand; for(int i = 0 ; i < n; i ++ ){ move_inside(i); val = press_button(); cand.insert(i); if(val > 1){ move_outside(i); } else{ in.insert(i); } } int dist = in.size(); int l = 1; int r = n/dist + 1; int mid; while(l + 1 < r){ mid = (l + r) / 2; if(mid * dist > n){ r = mid; continue; } for(auto i : cand){ if(!in.count(i)){ move_inside(i); val = press_button(); if(val > mid){ move_outside(i); } else{ in.insert(i); } } } if(in.size() == mid * dist){ l = mid; } else{ r = mid; cand = in; for(auto q : in){ move_outside(q); } in.clear(); } } return l; }

Compilation message (stderr)

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