Submission #434569

#TimeUsernameProblemLanguageResultExecution timeMemory
434569rqiCounting Mushrooms (IOI20_mushrooms)C++14
81.00 / 100
18 ms512 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long double db; #define pb push_back #define bk back() #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() mt19937 rng(127); int count_mushrooms(int n) { // cout << fixed << setprecision(6); // cout << db(226*100)/(db(98.0)) << "\n"; vi known[2]; vi untested; int ans = 1; known[0].pb(0); for(int i = 1; i < n; i++){ untested.pb(i); } shuffle(all(untested), rng); const int BLOCK = sqrt(n); vi p = vi{0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0}; while(sz(untested)){ int better_ind = 0; if(sz(known[1]) > sz(known[0])) better_ind = 1; if(true){ // cout << "known: " << sz(known[better_ind]) << "\n"; // cout << "untested: " << sz(untested) << "\n"; vi to_test; int to_go = sz(untested); int special = untested.bk; untested.pop_back(); to_test.pb(special); to_test.pb(known[better_ind][0]); vi tested; for(int i = 1; i < min(to_go, sz(known[better_ind])); i++){ tested.pb(untested.bk); to_test.pb(untested.bk); untested.pop_back(); to_test.pb(known[better_ind][i]); } bool do_special = 0; if(sz(untested) > 0){ do_special = 1; } int res = use_machine(to_test); int special_identity = better_ind; if(res % 2 == 0){ } else{ special_identity^=1; } known[special_identity].pb(special); if(special_identity == 0){ ans++; } // cout << res/2 << " " << sz(tested) << "\n"; if(res/2 == sz(tested)){ for(auto u: tested){ known[better_ind^1].pb(u); } } else if(res/2 == 0){ for(auto u: tested){ known[better_ind].pb(u); } } if(better_ind == 0){ ans+=sz(tested)-res/2; } else{ ans+=res/2; } } // else{ // cout << "DOING SPECIAL" << "\n"; // vi to_test; // vi tested; // cout << "sz(known[better_ind]):" << " " << sz(known[better_ind]) << "\n"; // cout << "sz(untested): " << sz(untested) << "\n"; // int to_go = sz(untested); // for(int i = 0; i < min(to_go, 2*sz(known[better_ind])); i++){ // tested.pb(untested.bk); untested.pop_back(); // } // cout << "tested: "; // for(auto u: tested){ // cout << u << " "; // } // cout << "\n"; // for(auto u: tested){ // cout << p[u] << " "; // } // cout << "\n"; // to_test.pb(tested[0]); // to_test.pb(known[better_ind][0]); // for(int i = 1; i+1 < sz(tested); i+=2){ // to_test.pb(tested[i]); // to_test.pb(tested[i+1]); // to_test.pb(known[better_ind][(i+1)/2]); // } // if(sz(tested) % 2 == 0){ // to_test.pb(tested.bk); // } // cout << "to_test: "; // for(auto u: to_test){ // cout << u << " "; // } // cout << "\n"; // for(auto u: to_test){ // cout << p[u] << " "; // } // cout << "\n"; // int res = use_machine(to_test); // cout << "res: " << res << "\n"; // // cout << sz(known[better_ind]) << "\n"; // // cout << res/2 << " " << sz(tested) << "\n"; // // if(res/2 == sz(tested)){ // // for(auto u: tested){ // // known[better_ind^1].pb(u); // // } // // } // // else if(res/2 == 0){ // // for(auto u: tested){ // // known[better_ind].pb(u); // // } // // } // if(better_ind == 0){ // ans+=sz(tested)-res; // } // else{ // ans+=res; // } // } } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:58:9: warning: variable 'do_special' set but not used [-Wunused-but-set-variable]
   58 |    bool do_special = 0;
      |         ^~~~~~~~~~
mushrooms.cpp:29:12: warning: unused variable 'BLOCK' [-Wunused-variable]
   29 |  const int BLOCK = sqrt(n);
      |            ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...