# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1054768 | Ignut | 드문 곤충 (IOI22_insects) | C++17 | 97 ms | 1024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* Ignut
started: 11.08.2024
now: 12.08.2024
████████████████████████████████████████████████████████████████████
████████████████████████████████ ████████████████████████████████
██████████████████████████████ ██████████████████████████████
██████ ██████████████████ ██████████████████ ██████
██████ ██████████████ ██████████████ ██████
██████ ██ ████████████ ████████████ ██ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ██████ ██████
██████ ██████ ██████████ ██████████ ██████ ██████
██████ ██████ ████████ ████████ ██████ ██████
██████ ██████ ██████ ██████ ██████ ██████
██████ ████ ████ ████ ████ ██████
██████ ██████████ ████ ██████████ ██████
██████ ██ ██████ ████████ ██████ ██ ██████
██████ ██████ ████████ ██████ ██████
██████ ██ ██ ██████
██████████████████████ ████ ████ ██████████████████████
████████████████████████ ██ ██ ████████████████████████
██████████████████████████ ██████████████████████████
██████████████████████████████ ██████████████████████████████
████████████████████████████████████████████████████████████████████
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void move_inside(int i);
void move_outside(int i);
int press_button();
int n;
vector<int> diff;
vector<int> in;
int prev_mid = 1;
map<int, int> cnt;
int Go(int maxCount) {
while (press_button() > maxCount) {
move_outside(in.back());
cnt[in.back()] --;
in.pop_back();
}
// if (prev_mid > maxCount) {
// while (!in.empty()) {
// cnt[in.back()] --;
// move_outside(in.back());
// in.pop_back();
// }
// }
// prev_mid = maxCount;
for (int i = 0; i < n; i ++) {
if (cnt[i] >= 1) continue;
move_inside(i);
in.push_back(i);
cnt[i] ++;
if (press_button() > maxCount) {
move_outside(i);
in.pop_back();
cnt[i] --;
}
}
int res = in.size();
if (maxCount == 1) diff = in;
return res;
}
int min_cardinality(int N) {
n = N;
int cntDiff = Go(1);
if (cntDiff <= 0) {
int minRes = N, sum = 0;
for (int i = 0; i < cntDiff - 1; i ++) {
vector<int> in;
in.push_back(diff[i]);
move_inside(diff[i]);
for (int j = diff[i] + 1; j < N; j ++) {
move_inside(j);
in.push_back(j);
// cout << "try " << j << ' ';
if (press_button() != in.size()) {
in.pop_back();
move_outside(j);
// cout << "! ";
}
}
// cout << '\n';
minRes = min(minRes, int(in.size()));
sum += in.size();
// cout << "have : " << in.size() << '\n';
// for (int val : in) cout << val << ' ';
// cout << '\n';
while (!in.empty()) {
move_outside(in.back());
in.pop_back();
}
}
minRes = min(minRes, N - sum);
return minRes;
}
int lo = 1, hi = N / cntDiff;
while (lo < hi) {
int mid = lo + (hi - lo + 1) / 2;
if (1ll * Go(mid) == 1ll * mid * cntDiff)
lo = mid;
else
hi = mid - 1;
}
return lo;
}
컴파일 시 표준 에러 (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... |