# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
933986 | EJIC_B_KEDAX | 버섯 세기 (IOI20_mushrooms) | C++17 | 4 ms | 904 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "mushrooms.h"
using ll = long long;
using namespace std;
mt19937 mt(time(nullptr));
int count_mushrooms(int n) {
vector<int> p(n - 1);
for (int i = 0; i < n - 1; i++) {
p[i] = i + 1;
}
// shuffle(p.begin(), p.end(), mt);
vector<int> a(1, 0), b;
int x = 0, ans = 1;
// if (n >= 100) {
// for (int i = 0; i < 10; i++) {
// if (use_machine({0, p[i]})) {
// b.push_back(p[i]);
// } else {
// a.push_back(p[i]);
// }
// }
// x = 10;
// }
while (x < n - 1) {
vector<int> ask;
if (a.size() > b.size()) {
int ind = 0, len = -1, start = x;
while (x < n - 1 && ind < a.size()) {
ask.push_back(a[ind++]);
ask.push_back(p[x++]);
len++;
}
int cnt = use_machine(ask);
if (cnt & 1) {
b.push_back(p[x - 1]);
} else {
a.push_back(p[x - 1]);
ans++;
}
cnt /= 2;
if (!cnt) {
for (int i = start; i < x - 1; i++) {
a.push_back(p[i]);
}
} else if (cnt == len) {
for (int i = start; i < x - 1; i++) {
b.push_back(p[i]);
}
}
ans += len - cnt;
} else {
int ind = 0, len = -1, start = x;
while (x < n - 1 && ind < b.size()) {
ask.push_back(b[ind++]);
ask.push_back(p[x++]);
len++;
}
int cnt = use_machine(ask);
if (cnt & 1) {
a.push_back(p[x - 1]);
ans++;
} else {
b.push_back(p[x - 1]);
}
cnt /= 2;
if (!cnt) {
for (int i = start; i < x - 1; i++) {
b.push_back(p[i]);
}
} else if (cnt == len) {
for (int i = start; i < x - 1; i++) {
a.push_back(p[i]);
}
}
ans += cnt;
}
}
assert(n <= 1000 || !b.empty());
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |