# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424049 | Mohammed_Atalah | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 200 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) {
vector<int> indices;
for (int i = 0; i < n; i++) {
indices.push_back(i);
}
if (use_machine(indices) == 0) {
return n;
}
int bs = 0;
int as = 1;
vector<int> a;
vector<int> b;
int last_index;
for (int i = 1; i < n; i++) {
std::vector<int> v;
v.push_back(0);
v.push_back(i);
if (use_machine(v) == 1) {
bs++;
b.push_back(i);
} else {
as++;
a.push_back(i);
}
if (a.size() == 50 || b.size() == 50) {
last_index = i + 1;
break;
}
}
if (a.size() != 20 && b.size() != 20) {
return n - bs;
}
int remain = n - last_index;
if (a.size() == 50) {
while (remain > 0) {
if (remain >= 19) {
vector<int> v;
v.push_back(a[0]);
for (int i = 1; i < 20; i++) {
v.push_back(last_index);
v.push_back(a[i]);
last_index++;
}
bs += use_machine(v) / 2;
remain -= 19;
} else {
vector<int> v;
v.push_back(a[0]);
for (int i = 1; i < remain + 1; i++) {
v.push_back(last_index);
v.push_back(a[i]);
last_index++;
}
bs += use_machine(v) / 2;
remain -= remain;
}
}
return n - bs;
} else if (b.size() == 50) {
while (remain > 0) {
if (remain >= 19) {
vector<int> v;
v.push_back(b[0]);
for (int i = 1; i < 20; i++) {
v.push_back(last_index);
v.push_back(b[i]);
last_index++;
}
as += use_machine(v) / 2;
remain -= 19;
// cout << as << endl;
} else {
vector<int> v;
v.push_back(b[0]);
for (int i = 1; i < remain + 1 ; i++) {
v.push_back(last_index);
v.push_back(b[i]);
last_index++;
}
as += use_machine(v) / 2;
remain -= remain;
}
}
return as;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |