# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494952 | PiejanVDC | 버섯 세기 (IOI20_mushrooms) | C++17 | 1 ms | 200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |