# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
620655 | 8e7 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 19 ms | 440 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.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#include "mushrooms.h"
int count_mushrooms(int n) {
int c = max(2, int(sqrt(n)));
vector<int> a, b;
vector<int> m;
a.push_back(0);
int i = 1, ret = 0, sw = 0;
for (;i < n;) {
m.clear();
vector<int> tmp;
if (a.size() >= b.size()) {
tmp = a;
sw = 0;
} else {
tmp = b;
sw = 1;
}
int num = 0;
for (int j = 0;j < tmp.size();j++) {
m.push_back(tmp[j]);
if (i < n) {
num++;
m.push_back(i);
i++;
}
}
//pary(m.begin(), m.end());
int res = use_machine(m);
if (num == tmp.size()) {
//debug("end", sw, res%2);
int bb = sw ^ (res%2);
if (bb) {
b.push_back(i-1);
} else {
a.push_back(i-1);
ret--;
}
}
if (sw) ret += (res+1)/2;
else ret += num - ((use_machine(m)+1)/2);
}
ret += a.size();
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |