제출 #407203

#제출 시각아이디문제언어결과실행 시간메모리
407203AmineTrabelsi버섯 세기 (IOI20_mushrooms)C++14
25 / 100
93 ms304 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+99<n;i+=100){ vector<int> m; for(int j=0;j<100;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 += 100; 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+100; if(a.size() >= 2)break; } /* for(auto i:a)cerr<<i<<" "; cerr<<'\n'; */ 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 || cnt == 2){ ans += 2; }else if(cnt == 3 || cnt == 4){ ans += 1; } ind = i+3; } } while(ind < n){ ans += use_machine({0,ind++}) == 0; } return ans; } /* 21 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...