제출 #886552

#제출 시각아이디문제언어결과실행 시간메모리
886552thinknoexit드문 곤충 (IOI22_insects)C++17
0 / 100
2 ms604 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; using ll = long long; int n; int sz = 0; set<int> rem; void putin(int x) { move_inside(x); sz++; } void putout(int x) { move_outside(x); sz--; } int val() { return press_button(); } int min_cardinality(int N) { n = N; putin(0); for (int i = 1;i < n;i++) { putin(i); if (val() == 2) { putout(i); rem.insert(i); } } int type = sz; if (type == n) return 1; int l = 1, r = n / sz; while (l < r) { int mid = (l + r + 1) / 2; stack<int> st, st2; for (auto& x : rem) { putin(x); if (val() > mid) { putout(x); st2.push(x); } else { st.push(x); } } if (sz == type * mid) { while (!st.empty()) { rem.erase(st.top()); st.pop(); } while (!st2.empty()) { putin(st2.top()); rem.erase(st2.top()); st2.pop(); } l = mid; } else { while (!st.empty()) { putout(st.top()); st.pop(); } r = mid - 1; } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...