# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944903 | nguyentunglam | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 984 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 count_mushrooms(int n) {
int j = 1;
vector<int> a, b;
a.push_back(0);
int ans = 0;
while (j < n) {
vector<int> query;
int total = 0;
if (a.size() > b.size()) {
for(int i = 0; i < a.size(); i++) {
query.push_back(a[i]);
if (i + 1 < a.size() && j < n) query.push_back(j++), total++;
}
if (j < n) query.push_back(j);
int result = use_machine(query);
if (j < n) {
if (result % 2) b.push_back(j);
else a.push_back(j);
j++;
}
ans += total - result / 2;
}
else {
for(int i = 0; i < b.size(); i++) {
query.push_back(b[i]);
if (i + 1 < b.size() && j < n) query.push_back(j++), total++;
}
if (j < n) query.push_back(j);
int result = use_machine(query);
if (j < n) {
if (result % 2) a.push_back(j);
else b.push_back(j);
j++;
}
ans += result / 2;
}
}
return ans + a.size();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |