# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436255 | Belgutei | Counting Mushrooms (IOI20_mushrooms) | C++17 | 15 ms | 304 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 ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
int c;
vector<int> v,v1;
vector<int> tur;
int count_mushrooms(int n) {
if(n<=200){
c=1;
for(int i=1; i<n; i++){
tur.clear();
tur.pb(0);
tur.pb(i);
c+=1-use_machine(tur);
}
return c;
}
//
v.pb(0);
tur.clear();
tur.pb(0);
tur.pb(1);
c=use_machine(tur);
if(c==0) v.pb(1);
else v1.pb(1);
//
if(v.size()==1){
tur.clear();
tur.pb(0);
tur.pb(2);
c=use_machine(tur);
if(c==0) v.pb(2);
else v1.pb(2);
}
//
if(v.size()==2){
for(int i=v.size()+v1.size()+1; i<200; i+=2){
tur.clear();
tur.pb(v[0]);
tur.pb(i-1);
tur.pb(v[1]);
tur.pb(i);
c=use_machine(tur);
if(c==0){
v.pb(i);
v.pb(i-1);
}
if(c==1){
v.pb(i-1);
v1.pb(i);
}
if(c==2){
v.pb(i);
v1.pb(i-1);
}
if(c==3){
v1.pb(i-1);
v1.pb(i);
}
}
}
else{
for(int i=v.size()+v1.size()+1; i<200; i+=2){
tur.clear();
tur.pb(v1[0]);
tur.pb(i-1);
tur.pb(v1[1]);
tur.pb(i);
c=use_machine(tur);
if(c==0){
v1.pb(i);
v1.pb(i-1);
}
if(c==1){
v1.pb(i-1);
v.pb(i);
}
if(c==2){
v1.pb(i);
v.pb(i-1);
}
if(c==3){
v.pb(i-1);
v.pb(i);
}
}
}
int ans=v.size();
if(v.size()>v1.size()){
int i=v.size()+v1.size();
while(i<n){
tur.clear();
int pos=0;
while(pos<v.size() && i<n){
tur.pb(v[pos]);
tur.pb(i);
i++;
pos++;
}
int val=use_machine(tur);
ans+=pos-(val+1)/2;
}
}
else{
int i=v.size()+v1.size();
while(i<n){
tur.clear();
int pos=0;
while(pos<v1.size() && i<n){
tur.pb(v1[pos]);
tur.pb(i);
i++;
pos++;
}
int val=use_machine(tur);
ans+=(val+1)/2;
}
}
return ans;
//int c2 = use_machine(m);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |