#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
vector<int> m(4);
int c1 = use_machine({ 0, 1 });
if (n == 2){
if (c1){
return 1;
}
return 2;
}
int c2 = use_machine({ 0, 2 });
bool inverse = false;
long long int ret;
vector<int> Alar, Bler;
Alar.push_back(0);
if (c1 == 0)
Alar.push_back(1);
else
Bler.push_back(1);
if (c2 == 0)
Alar.push_back(2);
else
Bler.push_back(2);
if (c1 == 0){
m[0] = 0;
m[2] = 1;
}else if (c2 == 0){
m[0] = 0;
m[2] = 2;
}else{
inverse = true;
m[0] = 1;
m[2] = 2;
}
for (int i = 0; 1 && 4 + i * 2 < n; i++){
m[1] = 3 + i * 2;
m[3] = 4 + i * 2;
c2 = use_machine(m);
if (c2 & 1){
if (inverse){
Alar.push_back(4 + i * 2);
}else
Bler.push_back(4 + i * 2);
}else{
if (inverse)
Bler.push_back(4 + i * 2);
else
Alar.push_back(4 + i * 2);
}
if (c2 >= 2){
if (inverse){
Alar.push_back(3 + i * 2);
}else
Bler.push_back(3 + i * 2);
}else{
if (inverse){
Bler.push_back(3 + i * 2);
}else
Alar.push_back(3 + i * 2);
}
}
if (Alar.size() + Bler.size() != n){
m.clear();
m.resize(2);
m[0] = 0;
m[1] = n - 1;
c2 = use_machine(m);
if (c2){
Bler.push_back(n - 1);
}else{
Alar.push_back(n - 1);
}
}
return Alar.size();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |