Submission #405817

#TimeUsernameProblemLanguageResultExecution timeMemory
405817ly20Counting Mushrooms (IOI20_mushrooms)C++17
0 / 100
3 ms300 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 21234; int count_mushrooms(int n) { int resp = 1; vector <int> va, vb; va.push_back(0); for(int i = 1; i < min(200, n); i++) { vector <int> temp; temp.push_back(i); temp.push_back(0); int at = use_machine(temp); if(at == 1) vb.push_back(i); else va.push_back(i); } if(n <= 200) return va.size(); int cur = 200; while(cur < n) { int at = 0; vector <int> temp; if(va.size() >= vb.size()) temp.push_back(va[0]); else temp.push_back(vb[0]); while(cur + at < n && at < max(va.size(), vb.size()) - 1) { temp.push_back(cur + at); at++; if(vb.size() > va.size()) temp.push_back(vb[at]); else temp.push_back(va[at]); } if(va.size() >= vb.size()) resp += (temp.size() - 1) / 2 - use_machine(temp) / 2; else resp += use_machine(temp) / 2; cur += at; } return resp; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:24:34: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   24 |         while(cur + at < n && at < max(va.size(), vb.size()) - 1) {
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...