Submission #661464

#TimeUsernameProblemLanguageResultExecution timeMemory
661464evenvalueCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
0 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>; using int64 = long long; using ld = long double; constexpr int kInf = 1e9 + 10; constexpr int64 kInf64 = 1e15 + 10; constexpr int kMod = 1e9 + 7; int count_mushrooms(int n) { int ans = 1 + (n % 2 == 0 ? 1 - use_machine({0, n - 1}) : 0); vector<int> segments; int cnt = 0; for (int i = 2; i < n; i += 2, cnt += 2) { const vector<int> foo = {i - 1, 0, i}; if (segments.size() + foo.size() > n) { ans += cnt - use_machine(segments); cnt = 0; segments.clear(); } segments.insert(segments.end(), foo.begin(), foo.end()); } if (segments.size() >= 3) ans += cnt - use_machine(segments); return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:23:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     if (segments.size() + foo.size() > n) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...