Submission #1188686

#TimeUsernameProblemLanguageResultExecution timeMemory
1188686hyakupCounting Mushrooms (IOI20_mushrooms)C++20
0 / 100
1 ms428 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> int count_mushrooms( int n ){ const int k = 100; vi a, b; a.push_back(0); int l = 1; while( a.size() < k && b.size() < k && l < n ){ vi v = { 0, l }; if( use_machine(v) == 1 ) b.push_back(l); else a.push_back(l); l++; } int cont = 0; bool invert = (a.size() == k); vi v = (( invert ) ? a : b ); while( l < n ){ int r = min(l + k, n); vi aux; for( int i = 0; i < k; i++ ){ aux.push_back(v[i]); if( l < r ) aux.push_back(l++); } int query = use_machine(aux); cont += (( invert ) ? (r - l) - (query + 1)/2 : (query + 1)/2 ); } return a.size() + cont; }
#Verdict Execution timeMemoryGrader output
Fetching results...