# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052330 | epicci23 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 5 ms | 600 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"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
#include "mushrooms.h"
using namespace std;
const int S = 142;
int count_mushrooms(int n){
vector<int> v[2];
int ansA=0;
v[0].push_back(0);
for(int i=1;i<n;){
if(i==n-1){
if(use_machine({0,i})) v[1].push_back(i);
else v[0].push_back(i);
i++;
break;
}
if(sz(v[0])<2 && sz(v[1])<2){
if(use_machine({0,i})) v[1].push_back(i);
else v[0].push_back(i);
i++;
continue;
}
else if(sz(v[0])<S && sz(v[1])<S){
if(sz(v[0])>=2){
int res = use_machine({v[0][0],i,v[0][1],i+1});
if(res&1) v[1].push_back(i+1);
else v[0].push_back(i+1);
if(res&2) v[1].push_back(i);
else v[0].push_back(i);
i+=2;
}
else{
int res = use_machine({v[1][0],i,v[1][1],i+1});
if(res&1) v[0].push_back(i+1);
else v[1].push_back(i+1);
if(res&2) v[0].push_back(i);
else v[1].push_back(i);
i+=2;
}
continue;
}
else{
if(sz(v[0])>=S){
vector<int> cur;
cur.push_back(v[0][0]);
int p=1;
while(i<n-1 && p<S){
cur.push_back(i++);
cur.push_back(v[0][p++]);
}
cur.push_back(i++);
int res=use_machine(cur);
if(!(res&1)) ansA++;
ansA+=sz(cur)/2-1-res/2;
}
else{
vector<int> cur;
cur.push_back(v[1][0]);
int p=1;
while(i<n-1 && p<S){
cur.push_back(i++);
cur.push_back(v[1][p++]);
}
cur.push_back(i++);
int res=use_machine(cur);
if(res&1) ansA++;
ansA+=res/2;
}
}
}
return sz(v[0]) + ansA;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |