제출 #633912

#제출 시각아이디문제언어결과실행 시간메모리
633912Kirill22드문 곤충 (IOI22_insects)C++17
99.95 / 100
61 ms328 KiB
#include<bits/stdc++.h> using namespace std; void move_inside(int i); void move_outside(int i); int press_button(); int min_cardinality(int n) { vector<int> used(n); for (int i = 0; i < n; i++) { move_inside(i); if (press_button() >= 2) { move_outside(i); } else { used[i] = 1; } } int cnt = accumulate(used.begin(), used.end(), 0); if (cnt == 1) { return n; } int l = 1, r = n / cnt + 1; auto start = used; vector<int> ban(n); while (l + 1 < r) { int m = (l + r) / 2; for (int i = 0; i < n; i++) { if (used[i] && !start[i]) { used[i] = 0; move_outside(i); } } vector<int> b; int cnt2 = accumulate(used.begin(), used.end(), 0); for (int i = 0; i < n; i++) { if (!used[i] && !ban[i]) { move_inside(i); int res = press_button(); if (res >= m + 1) { move_outside(i); b.push_back(i); } else { used[i] = 1; cnt2++; if (cnt2 == m * cnt) { break; } } } } //cout << m << " " << cnt2 << endl; //for (auto x : used) cout << x << " "; cout << endl; //for (auto x : ban) cout << x << " "; cout << endl; if (m * cnt == cnt2) { l = m; start = used; } else { r = m; for (auto i : b) { ban[i] = 1; } } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...