Submission #1018792

#TimeUsernameProblemLanguageResultExecution timeMemory
1018792BoasCounting Mushrooms (IOI20_mushrooms)C++17
25 / 100
73 ms1008 KiB
#include <bits/stdc++.h> using namespace std; #include "mushrooms.h" #define loop(x, i) for (int i = 0; i < x; i++) #define pb push_back #define ALL(x) (x).begin(), (x).end() typedef vector<int> vi; typedef pair<int, int> ii; typedef set<int> si; typedef vector<vi> vvi; int count_mushrooms(int n) { vi A = {0}, B; int c1 = use_machine({0, 1}); int i = 2; if (c1 == 1) { if (n == 2) return 1; B.pb(1); int c2 = use_machine({1, 2}); i++; if (c2 == 1) A.pb(2); else B.pb(2); } else { A.pb(1); } int x = 141; while (min(A.size(), B.size()) < x) { if (A.size() >= 2) { if (i + 1 >= n) break; int res = use_machine({A[0], i, A[1], i + 1}); if (res == 0) { A.pb(i); A.pb(i + 1); } else if (res == 1) { A.pb(i); } else if (res == 2) { A.pb(i + 1); } i += 2; } else { if (i + 1 >= n) break; int res = use_machine({B[0], i, B[1], i + 1}); if (res == 3) { A.pb(i); A.pb(i + 1); } else if (res == 2) { A.pb(i); } else if (res == 1) { A.pb(i + 1); } i += 2; } } if (i == n - 1) { if (use_machine({0, i}) == 0) A.pb(i); i++; } int res = A.size(); for (; i < n; i += x) { vi q; if (A.size() >= x) { q.pb(A[0]); int l = min(x, n - 1 - i); loop(l, j) { q.pb(i + j); q.pb(A[j + 1]); } res += (l - use_machine(q) / 2); q.clear(); } else { q.pb(B[0]); int l = min(x, n - 1 - i); loop(l, j) { q.pb(i + j); q.pb(B[j + 1]); } res += use_machine(q) / 2; q.clear(); } } return res; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:35:33: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   35 |  while (min(A.size(), B.size()) < x)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~^~~
mushrooms.cpp:88:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   88 |         if (A.size() >= x)
      |             ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...