# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
306136 | lolicon | 버섯 세기 (IOI20_mushrooms) | C++14 | 1 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int n) {
vector<int> arr(n);
int cnt = 0;
int k = sqrt(n);
for(int i = 1; i < 2 * k; i++) {
vector<int> m = {0, i};
if(use_machine(m)) {
arr[i] = 1; cnt++;
}
}
int ret = 2 * k - cnt;
if(cnt >= k) { // 1 is more
vector<int> keep;
for(int i = 0; i < 2 * k; i++) {
if(arr[i] == 1) keep.push_back(i);
}
int block = keep.size() - 1;
for(int i = 2 * k; i < n; i += block) {
vector<int> ask;
ask.push_back(0);
for(int j = 0, k = 1; j + i < n && j < block; j++) {
ask.push_back(j + i);
ask.push_back(keep[k]); k++;
}
assert(ask.size() > 1);
ret += use_machine(ask) / 2;
}
}
else { // 0 is more
vector<int> keep;
for(int i = 0; i < 2 * k; i++) {
if(arr[i] == 0) keep.push_back(i);
}
int block = keep.size() - 1;
for(int i = 2 * k; i < n; i += block) {
vector<int> ask;
ask.push_back(0);
for(int j = 0, k = 1; j + i < n && j < block; j++) {
ask.push_back(j + i);
ask.push_back(keep[k]); k++;
}
assert(ask.size() > 1);
ret += ((int)ask.size() / 2) - use_machine(ask) / 2;
}
}
// [0, 2 * k)
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |