Submission #620537

#TimeUsernameProblemLanguageResultExecution timeMemory
6205378e7Counting Mushrooms (IOI20_mushrooms)C++17
56.93 / 100
11 ms336 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #include "mushrooms.h" int count_mushrooms(int n) { int c = max(2, int(sqrt(n/2))); vector<int> a, b; vector<int> m; a.push_back(0); int i = 1; for (;i < n;i++) { m = {0, i}; if (use_machine(m) == 0) { a.push_back(i); } else { b.push_back(i); } if (a.size() >= c || b.size() >= c) { i++; break; } } int sw = 0; if (b.size() >= c) { sw = 1; swap(a, b); } int ret = 0; for (;i < n;) { m.clear(); int num = 0; for (int j = 0;j < c;j++) { m.push_back(a[j]); if (i < n) { num++; m.push_back(i); i++; } } if (sw) ret += ((use_machine(m)+1)/2); else ret += num - ((use_machine(m)+1)/2); } if (sw) ret += b.size(); else ret += a.size(); return ret; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:36:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   if (a.size() >= c || b.size() >= c) {
      |       ~~~~~~~~~^~~~
mushrooms.cpp:36:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   if (a.size() >= c || b.size() >= c) {
      |                        ~~~~~~~~~^~~~
mushrooms.cpp:42:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |  if (b.size() >= c) {
      |      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...