# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
312854 | DanerZein | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 256 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;
typedef vector<int> vi;
int punt[4];
void crear(int n,bool sw){
if(sw==1){
int p=n;
punt[0]=n;
int j=1;
while(true){
p--;
punt[j]=punt[j+1]=p;
j+=2;
if(p==0) break;
}
}
else{
int p=0;
punt[0]=0;
int j=1;
while(true){
p++;
punt[j]=punt[j+1]=p;
j+=2;
if(p==n) break;
}
}
}
int count_mushrooms(int n) {
int res=1;
int ca,cb;
vi pa,pb;
pa.push_back(0);
ca=cb=0;
for(int i=1;i<=min(2,n-1);i++){
vector<int> aux;
aux.push_back(0);
aux.push_back(i);
//cout<<use_machine(aux)<<" "<<i<<endl;
if(use_machine(aux)){
cb++;
pb.push_back(i);
}
else{
ca++;
res++;
pa.push_back(i);
}
}
ca++;
memset(punt,0,sizeof punt);
bool sw=0;
if(ca>=cb) sw=1;
crear(3,sw);
int c=max(ca,cb);
for(int i=3;i<n;i+=c){
vector<int> aux;
if(i+c>=n){
int h=n-i;
crear(h,sw);
}
for(int j=0;j<c;j++){
if(i+j<n)aux.push_back(i+j);
if(sw==1)
aux.push_back(pa[j]);
else
aux.push_back(pb[j]);
}
// for(int j=0;j<aux.size();j++) cout<<aux[j]<<" ";
// cout<<endl;
res+=(punt[use_machine(aux)]);
}
// cout<<res<<endl;
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |