# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405817 | ly20 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 3 ms | 300 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 = 1;
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;
while(cur < n) {
int at = 0;
vector <int> temp;
if(va.size() >= vb.size()) temp.push_back(va[0]);
else temp.push_back(vb[0]);
while(cur + at < n && at < max(va.size(), vb.size()) - 1) {
temp.push_back(cur + at);
at++;
if(vb.size() > va.size()) temp.push_back(vb[at]);
else temp.push_back(va[at]);
}
if(va.size() >= vb.size()) resp += (temp.size() - 1) / 2 - use_machine(temp) / 2;
else resp += use_machine(temp) / 2;
cur += at;
}
return resp;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |