Submission #405836

#TimeUsernameProblemLanguageResultExecution timeMemory
405836ly20Counting Mushrooms (IOI20_mushrooms)C++17
54.07 / 100
14 ms304 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 21234; int tst = 150; int count_mushrooms(int n) { int resp = 0; vector <int> va, vb; va.push_back(0); for(int i = 1; i < min(tst, n); i++) { vector <int> temp; temp.push_back(i); temp.push_back(0); int at = use_machine(temp); if(at == 1) vb.push_back(i); else va.push_back(i); } if(n <= tst) return va.size(); int cur = tst; int ta = va.size(), tb = vb.size(); vector <int> temp; vector <int> v; for(int i = 0; i < max(ta, tb); i++) { if(ta >= tb) v.push_back(va[i]); else v.push_back(vb[i]); } temp.push_back(v[0]); int qat = 1; for(int i = cur; i < n; i++) { temp.push_back(i); temp.push_back(v[qat]); if(qat == v.size() - 1) { if(ta >= tb) { resp += (temp.size() - 1) / 2 - use_machine(temp) / 2; } else resp += use_machine(temp) / 2; qat = 0; temp.clear(); temp.push_back(v[0]); } qat++; } if(temp.size() > 1) { if(ta >= tb) { resp += (temp.size() - 1) / 2 - use_machine(temp) / 2; } else resp += use_machine(temp) / 2; } return resp + va.size(); }

Compilation message (stderr)

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