Submission #630437

#TimeUsernameProblemLanguageResultExecution timeMemory
630437CyanForcesRarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define debug(...) //ignore typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef long double ld; int min_cardinality(int N) { int n = N; set<int> active; map<set<int>,int> queried; queried[active] = 0; auto add = [&](int x) { assert(!active.count(x)); active.emplace(x); move_inside(x); }; auto rem = [&](int x) { assert(active.count(x)); active.erase(x); move_outside(x); }; auto query = [&]() { if(!queried.count(active)) queried[active] = press_button(); return queried[active]; }; auto empty_all = [&]() { while(sz(active)) rem(*rbegin(active)); }; auto go = [&](int b) { rep(i,0,n) if(!active.count(i)) { add(i); if(query() > b) rem(i); } }; go(1); int distinct = sz(active); int l = 1, r = n; while(l+1 != r) { int m = (l+r)/2; empty_all(); go(m); if(sz(active) == m * distinct) l = m; else r = m; } return l; } // void move_inside(int i); // void move_outside(int i); // int press_button();
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...