# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310214 | Tc14 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 12 ms | 416 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
#define ve vector
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 10;
int count_mushrooms(int n) {
int ans, k, l, r, a;
bool z;
ve<int> M, A, B, C;
l = 100;
ans = 1;
A.push_back(0);
k = 2 * l + 1;
for (int i = 1; i < k; i++) {
if (i >= n) return ans;
M = {0, i};
if (use_machine(M) == 0) {
A.push_back(i);
ans++;
}
else B.push_back(i);
}
if (A.size() >= l + 1) {
z = false;
C = A;
}
else {
z = true;
C = B;
}
while (k < n) {
M = {};
a = 0;
for (int i = 0; i < l; i++) {
if (k >= n) break;
M.push_back(C[i]);
M.push_back(k);
k++;
a++;
}
M.push_back(C[a]);
r = use_machine(M);
if (z) ans += r / 2;
else ans += a - (r / 2);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |