Submission #828298

#TimeUsernameProblemLanguageResultExecution timeMemory
828298tomrukCounting Mushrooms (IOI20_mushrooms)C++17
10 / 100
142 ms704 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> a = {0},b; int last = 1; while(last < n && max(a.size(),b.size()) < n){ int num = use_machine({0,last}); if(num == 0) a.push_back(last); else b.push_back(last); last++; } int ca = 0,cb = 0; while(last < n){ if(a.size() > b.size()){ int cnt = 0; vector<int> ask; while(cnt < a.size() && last < n){ ask.push_back(last); ask.push_back(a[cnt]); cnt++; last++; } int num = use_machine(ask)/2; ca += cnt; ca -= num/2; ca -= num&1; } else{ int cnt = 0; vector<int> ask; while(cnt < b.size() && last < n){ ask.push_back(last); ask.push_back(b[cnt]); cnt++; last++; } int num = use_machine(ask)/2; ca += num/2; ca += num&1; } } return a.size() + ca; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:8:43: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
    8 |  while(last < n && max(a.size(),b.size()) < n){
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~
mushrooms.cpp:20:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    while(cnt < a.size() && last < n){
      |          ~~~~^~~~~~~~~~
mushrooms.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    while(cnt < b.size() && last < n){
      |          ~~~~^~~~~~~~~~
mushrooms.cpp:15:13: warning: unused variable 'cb' [-Wunused-variable]
   15 |  int ca = 0,cb = 0;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...