Submission #944903

#TimeUsernameProblemLanguageResultExecution timeMemory
944903nguyentunglamCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
6 ms984 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int j = 1; vector<int> a, b; a.push_back(0); int ans = 0; while (j < n) { vector<int> query; int total = 0; if (a.size() > b.size()) { for(int i = 0; i < a.size(); i++) { query.push_back(a[i]); if (i + 1 < a.size() && j < n) query.push_back(j++), total++; } if (j < n) query.push_back(j); int result = use_machine(query); if (j < n) { if (result % 2) b.push_back(j); else a.push_back(j); j++; } ans += total - result / 2; } else { for(int i = 0; i < b.size(); i++) { query.push_back(b[i]); if (i + 1 < b.size() && j < n) query.push_back(j++), total++; } if (j < n) query.push_back(j); int result = use_machine(query); if (j < n) { if (result % 2) a.push_back(j); else b.push_back(j); j++; } ans += result / 2; } } return ans + a.size(); }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:14:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       for(int i = 0; i < a.size(); i++) {
      |                      ~~^~~~~~~~~~
mushrooms.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (i + 1 < a.size() && j < n) query.push_back(j++), total++;
      |             ~~~~~~^~~~~~~~~~
mushrooms.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |       for(int i = 0; i < b.size(); i++) {
      |                      ~~^~~~~~~~~~
mushrooms.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (i + 1 < b.size() && j < n) query.push_back(j++), total++;
      |             ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...