QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398105 | #4565. Rarest Insects | hos_lyric | Compile Error | / | / | C++14 | 947b | 2024-04-24 22:14:23 | 2024-04-24 22:14:23 |
Judging History
answer
#include "insects.h"
#include <vector>
using std::vector;
#define push move_inside
#define pop move_outside
#define get press_button
// us -> vs, ws
vector<int> us, vs, ws;
void go(int thr) {
vs.clear();
ws.clear();
for (const int u : us) {
push(u);
if (get() <= thr) {
vs.push_back(u);
} else {
pop(u);
ws.push_back(u);
}
}
}
int min_cardinality(int N) {
us.resize(N);
for (int u = 0; u < N; ++u) us[u] = u;
go(1);
const int K = vs.size();
us.swap(ws);
assert(K >= 3);
// keep inside: lo insects of each type
int lo = 1, hi = N / K + 1;
for (; lo + 1 < hi; ) {
const int mid = (lo + hi) / 2;
go(mid);
if ((int)vs.size() >= K * (mid - lo)) {
lo = mid;
us.swap(ws);
} else {
hi = lo + (int)vs.size() / K + 1;
for (const int v : vs) pop(v);
us.swap(vs);
}
}
return lo;
}
詳細信息
implementer.cpp:8:8: warning: inline variables are only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 8 | static inline constexpr int kMaxQueries = 40000; | ^~~~~~ answer.code: In function ‘int min_cardinality(int)’: answer.code:34:3: error: ‘assert’ was not declared in this scope 34 | assert(K >= 3); | ^~~~~~ answer.code:4:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’? 3 | #include <vector> +++ |+#include <cassert> 4 | using std::vector;