Submission #1000614

#TimeUsernameProblemLanguageResultExecution timeMemory
1000614kunzaZa183Counting Mushrooms (IOI20_mushrooms)C++17
56.64 / 100
7 ms596 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int sup; vector<int> zeros(1, 0), ones; int res; for (int i = 1; i < n; i++) { vector<int> vi; vi.push_back(0); vi.push_back(i); // for (auto a : vi) cout << a << " "; // cout << "\n"; res = use_machine(vi); if (res == 1) ones.push_back(i); else zeros.push_back(i); sup = i; if (max(zeros.size(), ones.size()) == 100) break; } sup++; int zi = zeros.size(), oi = ones.size(); while (1) { if (sup == n) break; if (zeros.size() >= ones.size()) { vector<int> send; send.push_back(zeros.front()); int ct = 0; for (int i = 1; i < zeros.size(); i++) { if (sup == n) break; send.push_back(sup++); send.push_back(zeros[i]); ct++; } res = use_machine(send); res /= 2; oi += res, zi += ct - res; } else { vector<int> send; send.push_back(ones.front()); int ct = 0; for (int i = 1; i < ones.size(); i++) { if (sup == n) break; send.push_back(sup++); send.push_back(ones[i]); ct++; } res = use_machine(send); res /= 2; zi += res, oi += ct - res; } } return zi; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |       for (int i = 1; i < zeros.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~
mushrooms.cpp:45:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |       for (int i = 1; i < ones.size(); i++) {
      |                       ~~^~~~~~~~~~~~~
mushrooms.cpp:24:6: warning: 'sup' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |   sup++;
      |   ~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...