# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001515 | irmuun | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 440 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>
#include "mushrooms.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int count_mushrooms(int n){
int ans=0;
vector<int>a,b;
a.pb(0);
for(int i=1;i<min(n,200);i++){
int d=use_machine({0,i});
if(d==0){
a.pb(i);
}
else{
b.pb(i);
}
}
if(n<200){
return (int)a.size();
}
ans=a.size();
if(b.size()>a.size()){
int len=b.size();
len-=2;
for(int i=200;i<n;i+=len){
int r=min(i+len,n-1);
int cur=0;
vector<int>v;
v.pb(b[0]);
for(int j=i;j<=r;j++){
v.pb(j);
v.pb(b[++cur]);
}
for(int j=cur+1;j<b.size();j++){
v.pb(b[j]);
}
ans+=use_machine(v)/2;
}
}
else{
int len=a.size();
len-=2;
for(int i=200;i<n;i+=len){
int r=min(i+len,n-1);
int cur=0;
vector<int>v;
v.pb(a[0]);
int cnt=0;
for(int j=i;j<=r;j++){
v.pb(j);
cnt++;
v.pb(a[++cur]);
}
for(int j=cur+1;j<a.size();j++){
v.pb(a[j]);
}
ans+=cnt-use_machine(v)/2;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |