제출 #411648

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