Submission #780835

#TimeUsernameProblemLanguageResultExecution timeMemory
780835teamariaaCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
3 ms304 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; #define pb push_back int count_mushrooms(int n) { vector <int> m, aPos, bPos; int ans, cnt = 0, flag = 0; int capat = min(200, n); aPos.pb(0); // cout << capat << "\n"; for(int i = 1; i < capat; i ++) { // cout << "a\n"; m = {0, i}; ans = use_machine(m); if(ans) bPos.pb(i); else aPos.pb(i); } // cout << "fsfsd " << bPos.size() << "\n"; if(n < 200) return aPos.size(); int len; if(aPos.size() > bPos.size()) { m.resize(2 * aPos.size()); for(int i = 0; i < aPos.size(); i ++) m[2 * i] = aPos[i]; len = aPos.size(); } else { m.resize(2 * bPos.size()); flag = 1; for(int i = 0; i < bPos.size(); i ++) m[2 * i] = bPos[i]; len = bPos.size(); } cnt += aPos.size(); int i = 200; while(i < n) { int k = 0; while(i < n && k < len) { m[2 * k + 1] = i; i ++; k ++; } if(i == n && k < len) { m.resize(2 * k); ans = use_machine(m); if(flag) { cnt += (ans + 1) / 2; } else { int bNo = (ans + 1) / 2; cnt += k - bNo; } } ans = use_machine(m); if(flag) { cnt += (ans + 1) / 2; } else { int bNo = (ans + 1) / 2; cnt += len - bNo; } } return cnt; // for(int i = 0; i < (n - 200) / len; i ++) // { // for(int j = 200 + i * len; j < 200 + (i + 1) * len; j ++) // { // m[2 * j + 1] = j; // } // // ans = use_machine(m); // if(flag) // { // cnt += (ans + 1) / 2; // } // else // { // int bNo = (ans + 1) / 2; // cnt += len - bNo; // } // } }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i = 0; i < aPos.size(); i ++)
      |                        ~~^~~~~~~~~~~~~
mushrooms.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i = 0; i < bPos.size(); i ++)
      |                        ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...