Submission #308022

#TimeUsernameProblemLanguageResultExecution timeMemory
308022Tc14Counting Mushrooms (IOI20_mushrooms)C++17
80.14 / 100
9 ms384 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include "mushrooms.h" using namespace std; #define ve vector typedef long long ll; typedef pair<int, int> pii; const int INF = 1e9 + 10; int count_mushrooms(int n) { int ans, l, x, k, u, v, r, a; bool z; ve<int> M, A, B, C; l = 141; x = 2 * l + 1; ans = 1; A.push_back(0); for (int i = 1; i <= 2; i++) { if (i >= n) return ans; M = {0, i}; if (use_machine(M) == 0) { A.push_back(i); ans++; } else B.push_back(i); } if (A.size() >= 2) { z = false; C = A; } else { z = true; C = B; } k = 3; while (k < x) { if (k >= n) return ans; M = {C[0], k, C[1]}; u = k; k++; if (k < n) { M.push_back(k); v = k; k++; } else v = -1; r = use_machine(M); if ((r / 2 == 1) == z) { ans++; A.push_back(u); } else B.push_back(u); if (v != -1) { if ((r % 2 == 1) == z) { ans++; A.push_back(v); } else B.push_back(v); } } if (A.size() >= l + 1) { z = false; C = A; } else { z = true; C = B; } while (k < n) { M = {}; a = 0; for (int i = 0; i < l; i++) { if (k >= n) break; M.push_back(C[i]); M.push_back(k); k++; a++; } M.push_back(C[a]); r = use_machine(M); if (z) ans += r / 2; else ans += a - (r / 2); } return ans; }

Compilation message (stderr)

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