#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int n)
{
vector <int> arr[2];
arr[0] = {0};
for (int i=1;i<n;i++){
if (i+1 < n && arr[0].size() > 1){
int res = use_machine({arr[0][0], i, arr[0][1], i+1});
arr[(res&2)>>1^1].push_back(i);
arr[res&1^1].push_back(++i);
}else if (i+1 < n && arr[1].size() > 1){
int res = use_machine({arr[1][0], i, arr[1][1], i+1});
arr[(res&2)>>1].push_back(i);
arr[res&1].push_back(++i);
}
else arr[use_machine({0, i})].push_back(i);
}
return arr[0].size();
}
Compilation message
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:11: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
13 | arr[res&1^1].push_back(++i);
| ~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Answer is not correct. |
5 |
Halted |
0 ms |
0 KB |
- |