# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430485 | alireza_kaviani | Counting Mushrooms (IOI20_mushrooms) | C++17 | 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;
const int SQ = 101;
int calc(vector<int> vec , int l , int r){
int ans = 0;
for(int i = l ; i < r ; i += SQ - 1){
vector<int> v = {vec[0]};
for(int j = i ; j < min(r , i + SQ) ; j++){
v.push_back(j);
v.push_back(vec[j - i + 1]);
}
ans += v.size() - 1 - use_machine(v);
}
return ans / 2;
}
int count_mushrooms(int n) {
vector<int> A = {0} , B;
int cntA = 1 , cntB = 0;
for (int i = 1 ; i < n ; i++){
vector<int> v = {0 , i};
int x = use_machine(v);
if(x == 0){
cntA++;
A.push_back(i);
}
if(x == 1){
cntB++;
B.push_back(i);
}
if(cntA >= SQ || cntB >= SQ) break;
}
if(A.size() == SQ){
cntA += calc(A , A.size() + B.size() , n);
}
if(B.size() == SQ){
cntA += n - A.size() - B.size() - calc(B , A.size() + B.size() , n);
}
return cntA;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |