Submission #1186694

#TimeUsernameProblemLanguageResultExecution timeMemory
1186694the_coding_poohCounting Mushrooms (IOI20_mushrooms)C++20
56.93 / 100
3 ms428 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define uwu return using namespace std; const int MAGIC = 100; int count_mushrooms(int n) { vector <int> A, B; A.push_back(0); for(int i = 1; i < min(n, 2 * MAGIC); i++){ if(use_machine({0, i})) B.push_back(i); else A.push_back(i); } if(n - 1 <= 2 * MAGIC) return A.size(); int cnt_a = 0; for(int k = 2 * MAGIC; k < n; k += MAGIC){ if(A.size() >= MAGIC){ vector <int> tmp; for(int i = 0; i < MAGIC && k + i < n; i++){ tmp.push_back(A[i]); tmp.push_back(k + i); } cnt_a += tmp.size() / 2 - (use_machine(tmp) + 1) / 2; } else{ vector <int> tmp; for(int i = 0; i < MAGIC && k + i < n; i++){ tmp.push_back(B[i]); tmp.push_back(k + i); } cnt_a += (use_machine(tmp) + 1) / 2; } } return cnt_a + A.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...