제출 #411734

#제출 시각아이디문제언어결과실행 시간메모리
411734SuhaibSawalha1버섯 세기 (IOI20_mushrooms)C++17
45.56 / 100
16 ms456 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, 210); ++i) { a[use_machine({0, v.back()})].push_back(v.back()); v.pop_back(); } int ind = a[1].size() >= 101; while (v.size() >= 100) { vector<int> ask; for (int i = 0; i < 201; ++i) { if (i & 1) { ask.push_back(v.back()); v.pop_back(); } else { ask.push_back(a[ind][i / 2]); } } if (ind) { ans += use_machine(ask) / 2; } else { ans += 100 - use_machine(ask) / 2; } } if (v.size()) { for (int i : v) { ans += !use_machine({0, i}); } } return ans + a[0].size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...