# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
720710 | nguyentunglam | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 312 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.
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
int a[20010];
vector<int> A, B;
int count_mushrooms(int n) {
if (n == 2) return 1 + (use_machine({0, 1}) == 0);
a[1] = use_machine({0, 1});
a[2] = use_machine({0, 2});
int x, y, type = 0;
if (a[1] + a[2] == 2) {
type = 1;
x = 1; y = 2;
}
else {
type = 0;
if (a[1] == 0) x = 0, y = 1;
else x = 0, y = 2;
}
int T = min(300, n);
int ed = 2;
for(int i = 4; i < T; i += 2) {
int tmp = use_machine({x, i - 1, y, i});
if (tmp / 2 > 0) a[i - 1] = type ^ 1;
else a[i - 1] = type;
if (tmp % 2) a[i] = type ^ 1;
else a[i] = type;
ed = i;
}
for(int i = 0; i <= ed; i++) {
if (!a[i]) A.push_back(i);
else B.push_back(i);
}
bool ok = 0;
int tmp = 0;
if (A.size() < B.size()) swap(A, B), ok = 1;
int sz = A.size(), cnt = 0;
for(int i = ed + 1; i < n; i += sz) {
vector<int> ask;
for(int j = i; j < n && j < i + sz; j++) {
ask.push_back(A[j - i]);
ask.push_back(j);
cnt++;
}
tmp += (use_machine(ask) + 1) / 2;
}
if (!ok) return A.size() + cnt - tmp;
return B.size() + tmp;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |