제출 #627985

#제출 시각아이디문제언어결과실행 시간메모리
627985tutis드문 곤충 (IOI22_insects)C++17
82.04 / 100
105 ms352 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; mt19937_64 rnd(2); int min_cardinality(vector<int> x) { shuffle(x.begin(), x.end(), rnd); int N = x.size(); int add2 = 0; int add1 = 0; vector<int>y; int lo, hi; int c = 0; auto cnt = [&](int m)->int { vector<int>v; y = {}; int k = 0; bool jau = false; int liko = (int)x.size(); for (int i : x) { if (!jau) v.push_back(i); if (!jau) move_inside(i); if (!jau) k = press_button(); if (k + add1 == m + 1 || jau) { if (!jau) v.pop_back(); if (!jau) move_outside(i); y.push_back(i); } liko--; if (c != 0) if ((int)v.size() + add2 == m * c) jau = true; } int r = v.size(); for (int i : v) move_outside(i); return add2 + r; }; c = cnt(1); if (c * 2 > N) return 1; { x = y; add2 = c; add1 = 1; } lo = 1; hi = N / c; double bias = 3.5; bool fst = true; while (lo < hi) { int m = round((lo * bias + hi * 1.0) / (bias + 1)); 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 { if (m * c - k < m) lo = max(lo, m - (m * c - k)); hi = m - 1; } fst = false; } 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); }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(std::vector<int>)':
insects.cpp:58:10: warning: variable 'fst' set but not used [-Wunused-but-set-variable]
   58 |     bool fst = true;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...