# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306609 | chubyxdxd | Counting Mushrooms (IOI20_mushrooms) | C++17 | 2 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>
#define pb push_back
using namespace std;
int count_mushrooms(int n){
int ans=1;
vector<int> A;
vector<int> B;
A.pb(0);
int j;
for(int i=1;i<n;i++){
if(A.size()==100 or B.size()==100)break;
j=i;
vector<int> m;
m.pb(0);
m.pb(i);
int f=use_machine(m);
if(f==1)B.pb(i);
else A.pb(i);
}
if(A.size()==100){
ans=n;
int i=j+1;
vector<int> m;
while(i<n){
int l=0;
while(m.size()<198 and i<n){
m.pb(i);
i++;
m.pb(A[l]);
l++;
}
m.pb(A[l]);
int f=use_machine(m);
f=f/2;
ans-=f;
}
ans-=int(B.size());
return ans;
}
ans=0;
int i=j+1;
vector<int> m;
while(i<n){
int l=0;
while(m.size()<=198 and i<n){
m.pb(i);
i++;
m.pb(B[l]);
l++;
}
int f=use_machine(m);
f=f/2;
ans+=f;
}
ans+=int(A.size());
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |