# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052188 | mychecksedad | Counting Mushrooms (IOI20_mushrooms) | C++17 | 5 ms | 856 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;
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
int count_mushrooms(int n) {
vector<int> A, B;
A.pb(0);
int last = 1, add = 0;
while(last < n){
if(A.size() > B.size()){
vector<int> q;
int s = A.size();
for(int j = last; j < min(n, last + s); ++j){
q.pb(j);
q.pb(A[j - last]);
}
last = min(n, last + s);
int f = use_machine(q);
s = q.size()/2 - 1;
add += s - f/2;
if(f%2==0) A.pb(q[0]);
else B.pb(q[0]);
}else{
vector<int> q;
int s = B.size();
for(int j = last; j < min(n, last + s); ++j){
q.pb(j);
q.pb(B[j - last]);
}
int f = use_machine(q);
add += f/2;
if(f%2==1) A.pb(q[0]);
else B.pb(q[0]);
last = min(n, last + s);
}
}
return int(A.size()) + add;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |