# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052215 | noyancanturk | 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 "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int ind=1;
vector<int>t1,t2;
int count_mushrooms(int n) {
t1.pb(0);
while(ind<n&&t1.size()<2&&t2.size()<2){
int k=use_machine({0,ind});
if(k==1){
t2.pb(ind);
}else{
t1.pb(ind);
}
ind++;
}
for(int i=0;i<75&&ind<n;i++){
if(ind==n-1){
int k=use_machine({0,ind});
if(k==1){
t2.pb(ind);
}else{
t1.pb(ind);
}
ind++;
}else if(1<t1.size()){
int k=use_machine({t1[0],ind,t1[1],ind+1});
if(!k){
t1.pb(ind);
t1.pb(ind+1);
}else if(k==1){
t1.pb(ind);
t2.pb(ind+1);
}else if(k==2){
t2.pb(ind);
t1.pb(ind+1);
}else{
t2.pb(ind);
t2.pb(ind+1);
}
ind+=2;
}else{
int k=use_machine({t2[0],ind,t2[1],ind+1});
if(!k){
t2.pb(ind);
t2.pb(ind+1);
}else if(k==1){
t2.pb(ind);
t1.pb(ind+1);
}else if(k==2){
t1.pb(ind);
t2.pb(ind+1);
}else{
t1.pb(ind);
t1.pb(ind+1);
}
ind+=2;
}
}
int ans=0;
while(ind<n){
if(t2.size()<t1.size()){
vector<int>to;
int j=ind;
to.pb(t1[0]);
for(int i=1;i<t1.size()&&j<n;i++){
to.pb(j++);
to.pb(t1[i]);
}
if(j<n){
to.pb(j);
int k=use_machine(to);
ans+=(j-ind)-k/2;
if(k&1)t2.pb(j);
else t1.pb(j);
j++;
}else{
int k=use_machine(to);
ans+=(j-ind)-k/2;
}
ind=j;
}else{
vector<int>to;
int j=ind;
to.pb(t2[0]);
for(int i=1;i<t2.size()&&j<n;i++){
to.pb(j++);
to.pb(t2[i]);
}
if(j<n){
to.pb(j);
int k=use_machine(to);
ans+=k/2;
if(k&1)t1.pb(j);
else t2.pb(j);
j++;
}else{
int k=use_machine(to);
ans+=k/2;
}
ind=j;
}
}
return ans+t1.size();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |