# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414014 | cfalas | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 200 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 mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
int count_mushrooms(int n) {
int ans=1;
vi a;
vi b;
a.push_back(0);
FORi(i,1,min(n, 3)){
int x = use_machine({0,i});
if(x) b.push_back(i);
else a.push_back(i), ans++;
}
vi c;
FORi(i,3,n){
if(a.size()>=b.size()) c = a;
else c = b;
vi m;
FOR(j,c.size()){
if(i+j>=n) break;
m.push_back(c[j]), m.push_back(i+j);
}
int u = m.size()/2;
int x = use_machine(m);
int cur = 0;
cur+= u - (x+1)/2;
if((int)a.size()==u) ans+=cur;
else ans+=u-cur;
i+=c.size()-1;
if(a.size()>=b.size() && x%2==0) a.push_back(i);
else if(a.size()>=b.size() && x%2==1) b.push_back(i);
else if(a.size()<b.size() && x%2==1) a.push_back(i);
else if(a.size()<b.size() && x%2==0) b.push_back(i);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |