# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624763 | Dremix10 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 8 ms | 344 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;
int count_mushrooms(int n) {
vector<int> arr[2];
bool B = 1;
int i,k,x;
const int init = 200;
vector<int> temp;
temp.push_back(0);
arr[0].push_back(0);
int res = 0;
for(i=1;i<=min(n-1,2);i++){
temp.push_back(i);
x = use_machine(temp);
temp.pop_back();
arr[x].push_back(i);
}
temp.pop_back();
if(arr[0].size() > arr[1].size())
B = 0;
//assert(arr[B].size() >= 2);
temp.push_back(arr[B][0]);
temp.push_back(-1);
if(arr[B].size() > 1){
temp.push_back(arr[B][1]);
}
temp.push_back(-1);
for(k=3;k<=min(n-2,init-1);k+=2){
temp[1] = k;
temp[3] = k+1;
x = use_machine(temp);
if(x >= 2){
/// middle one is different
arr[B^1].push_back(k);
}
else{
arr[B].push_back(k);
}
if(x % 2){
/// right one is diff
arr[B^1].push_back(k+1);
}
else{
arr[B].push_back(k+1);
}
}
if(n%2 == 0 && k == n-1 && n != 2){
temp = {0,n-1};
x = use_machine(temp);
if(!x)res++;
}
k = init + 1;
res += arr[0].size();
while(k<n){
temp.clear();
B = 1;
if(arr[0].size() > arr[1].size())
B = 0;
for(i=0;i<arr[B].size() && k < n;i++){
temp.push_back(arr[B][i]);
temp.push_back(k);
k++;
}
x = use_machine(temp);
int diff = x/2;
if(x%2){
diff++;
arr[B^1].push_back(temp.back());
}
if(B)
res += diff;
else
res += temp.size()/2 - diff;
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |