# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
602076 | FatihSolak | Counting Mushrooms (IOI20_mushrooms) | C++17 | 10 ms | 352 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 "mushrooms.h"
#include <bits/stdc++.h>
#define N 20000
using namespace std;
int count_mushrooms(int n){
vector<int> a,b;
a.push_back(0);
int point = 1;
int cur = 0;
while(cur < 89 && n-point > max(a.size(),b.size()) ){
if(max(a.size(),b.size()) == 1){
if(use_machine({0,point})){
b.push_back(point);
}
else a.push_back(point);
point++;
}
else{
if(a.size() > b.size()){
vector<int> ask;
ask.push_back(a[0]);
ask.push_back(point++);
ask.push_back(a[1]);
ask.push_back(point++);
int val = use_machine(ask);
if(val < 2){
a.push_back(ask[1]);
}
else{
b.push_back(ask[1]);
}
if(val % 2 == 0){
a.push_back(ask[3]);
}
else{
b.push_back(ask[3]);
}
}
else{
vector<int> ask;
ask.push_back(b[0]);
ask.push_back(point++);
ask.push_back(b[1]);
ask.push_back(point++);
int val = use_machine(ask);
if(val < 2){
b.push_back(ask[1]);
}
else{
a.push_back(ask[1]);
}
if(val % 2 == 0){
b.push_back(ask[3]);
}
else{
a.push_back(ask[3]);
}
}
}
cur++;
}
int ret = a.size();
while(point < n){
int asz = a.size();
int bsz = b.size();
if(asz > bsz){
vector<int> nums;
int cnt = 0;
for(int j = point;j<min(n,point + asz);j++){
nums.push_back(a[cnt++]);
nums.push_back(j);
}
int sz = nums.size()/2;
int val = use_machine(nums);
point += asz;
if(val&1){
b.push_back(point-1);
}
else a.push_back(point-1);
ret += sz - (val + 1)/2;
}
else{
vector<int> nums;
int cnt = 0;
for(int j = point;j<min(n,point + bsz);j++){
nums.push_back(b[cnt++]);
nums.push_back(j);
}
int sz = nums.size()/2;
int val = use_machine(nums);
point += bsz;
if(val&1){
a.push_back(point-1);
}
else b.push_back(point-1);
ret += (val + 1)/2;
}
}
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |