Submission #407181

#TimeUsernameProblemLanguageResultExecution timeMemory
407181AmineTrabelsiCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
1 ms200 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int ans = 1; vector<int> a; int ind = 1; for(int i=1;i+9<n;i+=10){ vector<int> m; for(int j=0;j<10;j++){ m.push_back(i+j); } int cnt = use_machine(m); if(cnt == 0){ vector<int> t; t.push_back(0); for(int j=0;j<(int)m.size();j++){ t.push_back(m[j]); } int n_cnt = use_machine(t); if(n_cnt == 0){ ans += 10; for(auto j:m)a.push_back(i+j); } }else{ for(int j=0;j<(int)m.size();j++){ if(use_machine({0,m[j]}) == 0){ a.push_back(m[j]); ans++; } } } ind = i+10; if(a.size() >= 2)break; } if(a.size() >= 2){ for(int i=ind;i+2<n;i+=3){ vector<int> m = {0,i,a[0],i+1,a[1],i+2}; int cnt = use_machine(m); if(cnt == 0){ ans += 3; }else if(cnt == 1){ ans += 2; }else if(cnt == 2){ ans += 2; }else if(cnt == 3){ ans += 1; }else if(cnt == 4){ ans += 1; } } } while(ind < n){ ans += use_machine({0,ind++}) == 0; } return ans; } /* +3A len = 3 AAAAAA : 0 +3 AAAAAB : 1 +2 ABAAAA : 2 AAABAA : 2 +2 ABAAAB : 3 AAABAB : 3 +1 ABABAA : 4 +1 ABABAB : 5 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...