#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int res, a, b, m, sz;
vector<int> x, y;
int count_mushrooms(int n) {
if (n<=282)
{
for (int i=1; i<n; i++) if (use_machine(vector<int> {0, i})==0) res++;
return res+1;
}
x.push_back(0);
if (use_machine(vector<int> {0, 1})==0)
{
a=0, b=1, m=0;
x.push_back(1);
if (use_machine(vector<int> {1, 2})==0) x.push_back(2);
else y.push_back(2);
}
else if (use_machine(vector<int> {1, 2})==0) a=1, b=2, m=1, y.push_back(1), y.push_back(2);
else a=0, b=2, m=0, y.push_back(1), x.push_back(2);
for (int i=3; i<8; i+=2)
{
int tmp=use_machine(vector<int> {a, i, b, i+1});
if (m)
{
if (tmp==3) x.push_back(i), x.push_back(i+1);
else if (tmp==2) x.push_back(i), y.push_back(i+1);
else if (tmp==1) x.push_back(i+1), y.push_back(i);
else y.push_back(i), y.push_back(i+1);
}
else
{
if (tmp==3) y.push_back(i), y.push_back(i+1);
else if (tmp==2) y.push_back(i), x.push_back(i+1);
else if (tmp==2) y.push_back(i+1), x.push_back(i);
else x.push_back(i), x.push_back(i+1);
}
}
res=x.size();
if (x.size()>=y.size()) m=0, sz=x.size()-1;
else m=1, sz=y.size()-1;
/*
cout<<"debug x : ";
for (auto z:x) cout<<z<<' ';
cout<<'\n';
cout<<"debug y : ";
for (auto z:y) cout<<z<<' ';
cout<<'\n';
*/
for (int i=9; i<n; i+=sz)
{
vector<int> qrs;
int cnt=0;
for (int j=0; j<sz; j++)
{
if (m) qrs.push_back(y[j]);
else qrs.push_back(x[j]);
if (i+j<n) qrs.push_back(i+j), cnt++;
}
if (m) qrs.push_back(y.back());
else qrs.push_back(x.back());
int tmp=use_machine(qrs)/2;
if (m) res+=tmp;
else res+=cnt-tmp;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Partially correct |
2 ms |
344 KB |
Output is partially correct |
7 |
Partially correct |
15 ms |
344 KB |
Output is partially correct |
8 |
Partially correct |
15 ms |
344 KB |
Output is partially correct |
9 |
Partially correct |
19 ms |
344 KB |
Output is partially correct |
10 |
Partially correct |
18 ms |
344 KB |
Output is partially correct |
11 |
Incorrect |
23 ms |
344 KB |
Answer is not correct. |
12 |
Halted |
0 ms |
0 KB |
- |