#include <vector>
#include <iostream>
#include <tuple>
using namespace std;
int use_machine(std::vector<int> x);
std::pair<int,int> count(int n, std::vector<int> &v) {
int numV=0, numW=0;
for(int i=3; i+1<n; i+=2) {
int result = use_machine({v[0],i,v[1],i+1});
if (result%2) numW++;
else numV++;
if (result/2) numW++;
else numV++;
}
if (n%2) {
if(use_machine({v[0],v[n-1]})) numW++;
else numV++;
}
return {numV,numW};
}
int count_mushrooms(int n) {
vector<int> a, b; a.push_back(0);
int numA=0, numB=0;
for(int i=1; i<min(3,n); i++)
if (use_machine({0,i})) b.push_back(i);
else a.push_back(i);
if (n<=3) return a.size();
if (a.size()>=2) tie(numA,numB) = count(n,a);
else tie(numB,numA) = count(n,b);
numA += a.size(); numB += b.size();
return numA;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Answer is not correct. |
3 |
Halted |
0 ms |
0 KB |
- |