Submission #721459

#TimeUsernameProblemLanguageResultExecution timeMemory
721459vjudge1Counting Mushrooms (IOI20_mushrooms)C++17
0 / 100
5 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define N '\n'; #define VI <vector <int>> #define VVI <vector <vector <int>>> int count_mushrooms(int n){ int cnt = 1; if(n <= 226){ for(int i = 1; i < n; i++){ cnt += 1 - use_machine({0, i}); } return cnt; } vector <int> As = {0}; vector <int> Bs; int unt = 10; for(int i = 1; i < unt; i++){ bool q = use_machine({0,i}); if(q) Bs.push_back(i); else As.push_back(i); } cnt += As.size()-1; if(As.size() >= Bs.size()){ int i = unt; for(; i < n;){ vector<int> search; for(int j = 0 ; j < As.size() && i < n; j++, i++){ search.push_back(i); search.push_back(As[j]); } int q = use_machine(search); cnt += As.size()- q/2 + q % 2; } } else{ int i = unt; for(; i < n; ){ vector<int> search; for(int j = 0; j < Bs.size() && i < n; j++, i++){ search.push_back(i); search.push_back(Bs[j]); } int q = use_machine(search); cnt += 1 - q/2 + q % 2; } } // B A B A B A // B A A A B A B A return cnt; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:35:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(int j = 0 ; j < As.size() && i < n; j++, i++){
      |                             ~~^~~~~~~~~~~
mushrooms.cpp:47:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int j = 0; j < Bs.size() && i < n; j++, i++){
      |                            ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...