Submission #346061

#TimeUsernameProblemLanguageResultExecution timeMemory
346061Chayanin_KCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms364 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector <int> A, B, send; int res, nowi = 1, cnta = 1, cnt = 0; A.push_back(0); while(nowi < n){ if(A.size() >= B.size()){ cnt = 0; send.clear(); for(int x: A){ if(nowi >= n) break; send.push_back(x); send.push_back(nowi); nowi++; cnt++; } res = use_machine(send); if(res%2==1){ B.push_back(nowi-1); } else{ cnta += cnt - ((res+1) / 2); A.push_back(nowi-1); } } else{ send.clear(); for(int x: B){ if(nowi >= n) break; send.push_back(x); send.push_back(nowi); nowi++; } res = use_machine(send); if(res%2==1){ A.push_back(nowi-1); cnta += (res+1) / 2; } else{ B.push_back(nowi-1); } } } return cnta; }
#Verdict Execution timeMemoryGrader output
Fetching results...