# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
620528 | 8e7 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 19 ms | 316 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)) * 3 / 4);
vector<int> a, b;
vector<int> m;
a.push_back(0);
int i = 1;
for (;i < n;i++) {
m = {0, i};
if (use_machine(m) == 0) {
a.push_back(i);
} else {
b.push_back(i);
}
if (a.size() >= c || b.size() >= c) {
i++;
break;
}
}
int sw = 0;
if (b.size() >= c) {
sw = 1;
swap(a, b);
}
int ret = 0;
for (;i < n;) {
m.clear();
int num = 0;
for (int j = 0;j < c;j++) {
m.push_back(a[j]);
if (j != c - 1 && i < n) {
num++;
m.push_back(i);
i++;
}
}
if (sw) ret += (use_machine(m)/2);
else ret += num - (use_machine(m)/2);
}
if (sw) ret += b.size();
else ret += a.size();
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |