제출 #411730

#제출 시각아이디문제언어결과실행 시간메모리
411730SuhaibSawalha1버섯 세기 (IOI20_mushrooms)C++17
25 / 100
140 ms384 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int ans = 0; vector<int> a[2], v(n - 1); iota(v.begin(), v.end(), 1); a[0] = {0}; for (int i = 1; i < min(n, 5); ++i) { a[use_machine({0, v.back()})].push_back(v.back()); v.pop_back(); } while (v.size() > 1) { int res; if (a[0].size() >= 3) { res = use_machine({a[0][0], v.back(), a[0][1], v[v.size() - 2], a[0][2]}); ans += (res == 2) + 2 * (res == 0); } else { res = use_machine({a[1][0], v.back(), a[1][1], v[v.size() - 2], a[1][2]}); ans += (res == 2) + 2 * (res == 4); } v.pop_back(); v.pop_back(); } if (v.size()) { ans += !use_machine({0, v[0]}); } return ans + a[0].size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...