#include <bits/stdc++.h>
#include "mushrooms.h"
#define sz(x) (int)x.size()
using namespace std;
const int len = 200;
int count_mushrooms(int n) {
vector<int> A, B;
for (int i = 1; i < min(n, len + 1); i++) {
(use_machine({0, i}) ? B : A).push_back(i);
}
int ans = A.size() + 1;
bool inv = 0;
if (A.size() < B.size()) swap(A, B), inv = 1;
vector<int> cur;
for (int j = len + 1, on = 0; j < n; j++) {
if (on == sz(A)) {
int res = use_machine(cur);
ans += inv ? res : sz(cur) - sz(A) - res;
cur.clear(), on = 0;
}
cur.emplace_back(j);
cur.emplace_back(A[on++]);
}
if (cur.size()) {
int res = use_machine(cur);
ans += inv ? res : sz(cur) - sz(A) - res;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Answer is not correct. |
7 |
Halted |
0 ms |
0 KB |
- |