# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405832 | ly20 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 3 ms | 328 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;
const int MAXN = 21234;
int count_mushrooms(int n) {
int resp = 0;
vector <int> va, vb;
va.push_back(0);
for(int i = 1; i < min(200, n); i++) {
vector <int> temp;
temp.push_back(i);
temp.push_back(0);
int at = use_machine(temp);
if(at == 1) vb.push_back(i);
else va.push_back(i);
}
if(n <= 200) return va.size();
int cur = 200;
int ta = va.size(), tb = vb.size();
vector <int> temp;
vector <int> v;
for(int i = 0; i < max(ta, tb); i++) {
if(ta >= tb) v.push_back(va[i]);
else v.push_back(vb[i]);
}
temp.push_back(v[0]);
int qat = 1;
for(int i = cur; i < n; i++) {
temp.push_back(i);
temp.push_back(v[qat]);
if(qat == v.size() - 1) {
if(ta >= tb) {
resp += (temp.size() - 1) / 2 - use_machine(temp) / 2;
}
else resp += use_machine(temp) / 2;
qat = 1;
temp.clear();
temp.push_back(v[0]);
}
}
if(temp.size() > 1) {
if(ta >= tb) {
resp += (temp.size() - 1) / 2 - use_machine(temp) / 2;
}
else resp += use_machine(temp) / 2;
}
return resp + va.size();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |