Submission #830549

#TimeUsernameProblemLanguageResultExecution timeMemory
830549tolbiRarest Insects (IOI22_insects)C++17
50 / 100
164 ms428 KiB
#include <bits/stdc++.h> using namespace std; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #include "insects.h" int min_cardinality(int n) { function<int(int)> f; vector<int> hash(n); iota(hash.begin(), hash.end(), 0); for (int i = n-1; i >= 0; i--){ swap(hash[i],hash[ayahya()%(i+1)]); } f = [&](int x)->int{ int ans = 0; vector<int> crr; for (int i = 0; i < n; i++){ crr.push_back(hash[i]); move_inside(hash[i]); if (press_button()>x){ ans++; crr.pop_back(); move_outside(hash[i]); } } for (int i = 0; i < crr.size(); ++i) { move_outside(crr[i]); } return ans; }; int diff = n-f(1); if (diff==1) return n; int l = 1, r = n/diff; while (l<r){ int mid = l+(r-l+1)/2; if (f(mid)>n-(mid*diff)){ r=mid-1; } else l = mid; } return l; }

Compilation message (stderr)

insects.cpp: In lambda function:
insects.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i = 0; i < crr.size(); ++i)
      |                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...