Submission #699791

#TimeUsernameProblemLanguageResultExecution timeMemory
699791grossly_overconfidentCounting Mushrooms (IOI20_mushrooms)C++14
Compilation error
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { if (n < 220){ int a = 1; for (int i = 1; i < n; ++i){ a += 1 - use_machine({ 0, i }); } return a; } vector<int> a(1, 0); vector<int> b; if (use_machine({ 0, 1 }) == 1){ b.push_back(1); } else{ a.push_back(1); } if (use_machine({ 0, 2 }) == 1){ b.push_back(2); } else{ a.push_back(2); } for (int i = 3; i <= 150; i += 2){ if (a.size() > b.size()){ int h = use_machine({ i, a[0], i + 1, a[1]}); if (h % 2){ a.push_back(i); } else{ b.push_back(i); } if (h < 2){ a.push_back(i + 1); } else{ b.push_back(i + 1); } } else{ int h = use_machine({ i, b[0], i + 1, b[1]}); if (h % 2){ b.push_back(i); } else{ a.push_back(i); } if (h < 2){ b.push_back(i + 1); } else{ a.push_back(i + 1); } } } int i = 151; int tally = a.size(); while (true){ if (a.size() < b.size()){ vector<int> p; int w = i; for (int j = 0; j < b.size(); ++j){ p.push_back(i); p.push_back(b[j]); i++; if (i == n){ break; } } int h = use_machine(p); if (h % 2 == 0){ b.push_back(w); tally += h / 2; } else{ a.push_back(w); tally++; tally += (h - 1) / 2; } if (i == n){ return tally; } } else{ vector<int> p; int w = i; for (int j = 0; j < a.size(); ++j){ p.push_back(i); p.push_back(a[j]); i++; if (i == n){ break; } } h = use_machine(p); if (h % 2 == 0){ a.push_back(w); tally++; tally += (i - w) - (h / 2); } else{ b.push_back(w); tally += (i - w) - ((h - 1) / 2); } if (i == n){ return tally; } } if (i == n){ return tally; } } }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for (int j = 0; j < b.size(); ++j){
      |                    ~~^~~~~~~~~~
mushrooms.cpp:91:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |    for (int j = 0; j < a.size(); ++j){
      |                    ~~^~~~~~~~~~
mushrooms.cpp:99:4: error: 'h' was not declared in this scope
   99 |    h = use_machine(p);
      |    ^