# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
607570 | keta_tsimakuridze | Counting Mushrooms (IOI20_mushrooms) | C++14 | 0 ms | 208 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>
using namespace std;
int count_mushrooms(int n) {
vector<int> A, B, x;
A.push_back(0);
int cntA = 1;
while(x.size()) {
if(A.size() >= B.size()) {
vector<int> v;
int nn = 0;
for(int i = 0; i < A.size(); i++) {
v.push_back(A[i]);
v.push_back(x.back());
x.pop_back(); ++nn;
if(!x.size()) break;
}
int x = use_machine(v);
cntA += nn - (x / 2 + x % 2);
if(x % 2) B.push_back(v.back());
else A.push_back(v.back());
} else {
vector<int> v;
int nn = 0;
for(int i = 0; i < B.size(); i++) {
v.push_back(B[i]);
v.push_back(x.back());
x.pop_back(); ++nn;
if(!x.size()) break;
}
int x = use_machine(v);
cntA += (x / 2 + x % 2);
if(x % 2 == 0) B.push_back(v.back());
else A.push_back(v.back());
}
}
return cntA;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |