제출 #627848

#제출 시각아이디문제언어결과실행 시간메모리
627848tutis드문 곤충 (IOI22_insects)C++17
82.04 / 100
113 ms364 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(vector<int> x) { int N = x.size(); int add2 = 0; int add1 = 0; vector<int>y; auto cnt = [&](int c)->int { vector<int>v; y = {}; for (int i : x) { v.push_back(i); move_inside(i); int k = press_button(); if (k + add1 == c + 1) { v.pop_back(); move_outside(i); y.push_back(i); } } int r = v.size(); for (int i : v) move_outside(i); return add2 + r; }; int c = cnt(1); if (c * 2 > N) return 1; { x = y; add2 = c; add1 = 1; } int lo = 1; int hi = N / c; while (lo < hi) { int m = round((lo * 3.0 + hi * 1.0) / 4); m = max(m, lo + 1); m = min(m, hi); int k = cnt(m); if (k == m * c) { lo = m; x = y; add2 = m * c; add1 = m; } else hi = m - 1; } return lo; } int min_cardinality(int N) { vector<int>v; for (int i = 0; i < N; i++) v.push_back(i); return min_cardinality(v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...