# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1054622 | shmax | 드문 곤충 (IOI22_insects) | C++17 | 203 ms | 856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define len(x) ((int)(x.size()))
#define all(x) x.begin(), x.end()
template<typename T>
using vec = vector<T>;
template<typename T>
using graph = vec<vec<T>>;
mt19937 rnd(2312);
int min_cardinality(int n) {
graph<int> g(n);
auto connect = [&](int u, int v) {
g[u].push_back(v);
g[v].push_back(u);
};
vec<int> ord(n);
int diff = 0;
vec<int> in;
for (int i = 0; i < n; i++) {
move_inside(i);
if (press_button() > 1) {
move_outside(i);
} else {
diff++;
in.push_back(i);
}
}
for (auto x: in) {
move_outside(x);
}
int tcnt = n;
int tl = 1;
int tr = tcnt;
iota(all(ord), 0);
auto check = [&](int x) {
int cnt = 0;
vec<int> ins;
for (int i: ord) {
move_inside(i);
if (press_button() > x) {
move_outside(i);
} else {
cnt++;
ins.push_back(i);
}
if (cnt == x * diff) break;
}
for (auto y: ins) {
move_outside(y);
}
tcnt = cnt;
return cnt == x * diff;
};
while (tl < tr) {
int tm = tr / diff;
if (check(tm)) {
tl = tm;
tr = tm;
} else {
tr = tcnt;
}
}
return tl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |