# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697070 | garam1732 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 3 ms | 304 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;
vector<int> a, b;
int cnt = 100;
int count_mushrooms(int n) {
a.push_back(0);
std::vector<int> m;
for(int i = 1; i < n && i <= 2*cnt; i++) {
m = {0, i};
int x = use_machine(m);
if(x) b.push_back(i);
else a.push_back(i);
}
if(a.size() + b.size() == n) return a.size();
int res = a.size();
if(a.size() >= cnt) {
int idx = 2*cnt+1;
while(idx < n) {
m.push_back(a[0]);
for(int i = 1; i < a.size(); i++) {
if(idx < n) m.push_back(idx++);
m.push_back(a[i]);
}
res += (int)m.size()-1-use_machine(m)/2;
}
}
else {
int idx = 2*cnt+1;
while(idx < n) {
m.push_back(b[0]);
for(int i = 1; i < b.size(); i++) {
if(idx < n) m.push_back(idx++);
m.push_back(b[i]);
}
res += use_machine(m)/2;
}
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |