Submission #414016

#TimeUsernameProblemLanguageResultExecution timeMemory
414016cfalasCounting Mushrooms (IOI20_mushrooms)C++14
80.71 / 100
10 ms456 KiB
#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; assert(c.size()>=2); 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(a.size()==c.size()) ans+=cur; else ans+=u-cur; i+=u-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 timeMemoryGrader output
Fetching results...