# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
494952 | PiejanVDC | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "mushrooms.h"
int count_mushrooms(int n) {
int a=1,b=0;
int goal = (n+1)/2;
int i=1;
vector<int>posA = {0},posB;
while(a < goal && b < goal) {
int x = use_machine({0,i});
if(x) b++,posB.push_back(i);
else a++,posA.push_back(i);
i++;
}
bool use = (a == goal ? 1 : 0);
int ans = 1;
while(i < n) {
vector<int>check;
int p = 0;
int sz = n - i;
for(int k = 0 ; k < min(goal + goal - 1, 2*sz+1) ; k++) {
if(k&1) check.push_back(i++);
else check.push_back((use ? posA[p++] : posB[p++]));
}
int cnt = use_machine(check);
ans += goal - 1 - cnt/2;
assert(goal - 1 - cnt/2 >= 0);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |