제출 #1084703

#제출 시각아이디문제언어결과실행 시간메모리
1084703siewjh드문 곤충 (IOI22_insects)C++17
100 / 100
46 ms704 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N){ random_device rd; mt19937 g(rd()); vector<int> active; int cnt = 0; for (int i = 0; i < N; i++){ move_inside(i); if (press_button() == 1) cnt++; else{ move_outside(i); active.push_back(i); } } shuffle(active.begin(), active.end(), g); int ans = 1, l = 2, r = N / cnt, sz = cnt; while (l <= r){ int m = (l + r) >> 1; vector<int> iv, ov; for (int i : active){ if (sz == cnt * m){ ov.push_back(i); continue; } move_inside(i); if (press_button() <= m){ iv.push_back(i); sz++; } else{ move_outside(i); ov.push_back(i); } } if (sz == cnt * m){ ans = m; l = m + 1; active = ov; } else{ r = m - 1; for (int i : iv) move_outside(i); sz -= iv.size(); active = iv; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...