# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427183 | AugustinasJucas | Counting Mushrooms (IOI20_mushrooms) | C++14 | 24 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 <bits/stdc++.h>
using namespace std;
#include "mushrooms.h"
int count_mushrooms(int n) {
if(n <= 10){
int A = 1, B = 0;
for(int i = 1; i < n; i++){
int kek = use_machine({0, i});
if(kek == 0){
A++;
}else{
B++;
}
}
return A;
}
int ans = 1e9;
int kekViename = -1;
for(int i = 1; i < n; i++){
int st = 2 * i + (n - 2*i) / (i) + 1; // kuo tiksliau, tuo geriau!
if(ans > st){
ans = st;
kekViename = i;
}
}
int lastTaken = 0;
vector<int> A = {0}, B;
int left = n-1;
int answ = 1;
//cout << "ieskosiu pirmuju " << kekViename << " * 2 skaiciu!" << endl;
for(int i = 1; i <= kekViename * 2; i++){
int kek = use_machine({0, i});
if(kek == 0){
A.push_back(i);
answ++;
}else{
B.push_back(i);
}
left--;
lastTaken = i;
if((int)A.size() >= kekViename+1 || (int)B.size() >= kekViename+1){
break;
}
}
//cout << "radau! A: "; for(auto x : A) cout << x<< " ";
//cout << ". B: "; for(auto x : B) cout << x << " "; cout << endl << endl;
while(true){
if(A.size() > B.size()){
//cout << "I tarpus desim A " << endl;
// desim A ir i tarpus kitka
vector<int> st;
int ind = 1;
st.push_back(A[0]);
for(int i = 0; i < min(left, (int) A.size()-1); i++){
st.push_back(++lastTaken);
st.push_back(A[ind++]);
}
int visoBuvo = min(left, (int) A.size()-1);
//cout << "gaunam st: "; for(auto x : st) cout << x << " "; cout << endl;
left -= min(left, (int) A.size()-1);
int rz = use_machine(st);
//cout << "pridedame " << visoBuvo << " - " << rz << "/2\n\n";
answ += visoBuvo - rz/2;
}else{
vector<int> st;
int ind = 1;
st.push_back(B[0]);
for(int i = 0; i < min(left, (int) B.size()-1); i++){
st.push_back(++lastTaken);
st.push_back(B[ind++]);
}
left -= min(left, (int) B.size()-1);
int rz = use_machine(st);
answ += rz/2;
}
if(left == 0) break;
}
return answ;
}
/*
11
0 0 0 1 1 0 1 1 0 0 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |