# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423199 | xyz | Counting Mushrooms (IOI20_mushrooms) | C++17 | 15 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 <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef long long ll;
const int m = 140;
int count_mushrooms(int n){
vector<int> A, B;
A = {0};
int go = 2 * m + 5;
for(int i = 1; i < min(n, go); i ++){
vector<int> ask = {0, i};
int x = use_machine(ask);
if(!x)
A.push_back(i);
else
B.push_back(i);
}
int result = A.size();
for(int i = go; i < n; i += m){
if(A.size() >= B.size()){
vector<int> ask = {A[0]};
int cur = 1;
for(int j = i; j < min(n, i + m); j ++){
ask.push_back(j);
ask.push_back(A[cur]);
++ cur;
}
int x = use_machine(ask), y = ask.size();
result += ((y - 1) - x) / 2;
}else{
vector<int> ask = {B[0]};
int cur = 1;
for(int j = i; j < min(n, i + m); j ++){
ask.push_back(j);
ask.push_back(B[cur]);
++ cur;
}
int x = use_machine(ask);
result += x / 2;
}
}
return result;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |