Submission #1087129

#TimeUsernameProblemLanguageResultExecution timeMemory
1087129epicci23Counting Mushrooms (IOI20_mushrooms)C++17
75.59 / 100
6 ms600 KiB
#include "bits/stdc++.h" //#define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() #include "mushrooms.h" using namespace std; const int S = 100; int count_mushrooms(int n){ vector<int> v[2]; int ansA=0; v[0].push_back(0); for(int i=1;i<n;){ if(i==n-1){ if(use_machine({0,i})) v[1].push_back(i); else v[0].push_back(i); i++; break; } if(sz(v[0])<2 && sz(v[1])<2){ if(use_machine({0,i})) v[1].push_back(i); else v[0].push_back(i); i++; continue; } else if(sz(v[0])<S && sz(v[1])<S){ if(sz(v[0])>=2){ int res = use_machine({v[0][0],i,v[0][1],i+1}); if(res&1) v[1].push_back(i+1); else v[0].push_back(i+1); if(res&2) v[1].push_back(i); else v[0].push_back(i); i+=2; } else{ int res = use_machine({v[1][0],i,v[1][1],i+1}); if(res&1) v[0].push_back(i+1); else v[1].push_back(i+1); if(res&2) v[0].push_back(i); else v[1].push_back(i); i+=2; } continue; } else{ if(sz(v[0])>=S){ vector<int> cur; cur.push_back(v[0][0]); int p=1; while(i<n-1 && p<S){ cur.push_back(i++); cur.push_back(v[0][p++]); } cur.push_back(i++); int res=use_machine(cur); if(!(res&1)) ansA++; ansA+=sz(cur)/2-1-res/2; } else{ vector<int> cur; cur.push_back(v[1][0]); int p=1; while(i<n-1 && p<S){ cur.push_back(i++); cur.push_back(v[1][p++]); } cur.push_back(i++); int res=use_machine(cur); if(res&1) ansA++; ansA+=res/2; } } } return sz(v[0]) + ansA; }
#Verdict Execution timeMemoryGrader output
Fetching results...