Submission #607575

#TimeUsernameProblemLanguageResultExecution timeMemory
607575keta_tsimakuridzeCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
9 ms464 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> A, B, x; for(int i = 1; i < n; i++) x.push_back(i); A.push_back(0); int cntA = 1; while(x.size()) { if(A.size() >= B.size()) { vector<int> v; int nn = 0; for(int i = 0; i < A.size(); i++) { v.push_back(A[i]); v.push_back(x.back()); x.pop_back(); ++nn; if(!x.size()) break; } int x = use_machine(v); cntA += nn - (x / 2 + x % 2); if(x % 2) B.push_back(v.back()); else A.push_back(v.back()); } else { vector<int> v; int nn = 0; for(int i = 0; i < B.size(); i++) { v.push_back(B[i]); v.push_back(x.back()); x.pop_back(); ++nn; if(!x.size()) break; } int x = use_machine(v); cntA += (x / 2 + x % 2); if(x % 2 == 0) B.push_back(v.back()); else A.push_back(v.back()); } } return cntA; }

Compilation message (stderr)

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