# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
951737 | Trisanu_Das | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 756 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
int b = max(3, (int) sqrt(n) + 20);
vector<int> ones;
vector<int> zeros = {0};
for (int i = 1; i < min(n, b); ++i) {
if (use_machine({0, i}) == 0) {
zeros.push_back(i);
} else {
ones.push_back(i);
}
}
int cnt = 0;
int p = b;
while (p < n) {
vector<int> ask;
int pv = 1;
if (ones.size() > zeros.size()) {
ask.push_back(ones[0]);
while (p < n && pv < (int) ones.size()) {
ask.push_back(p++);
ask.push_back(ones[pv++]);
}
cnt += use_machine(ask) / 2;
} else {
ask.push_back(zeros[0]);
int tot = 0;
while (p < n && pv < (int) zeros.size()) {
ask.push_back(p++);
ask.push_back(zeros[pv++]);
tot += 2;
}
int tmp = use_machine(ask);
cnt += (tot - tmp) / 2;
}
}
return zeros.size() + cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |