#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef long long ll;
int kVal, kA, kB;
void get(vector<ll> &m, int a, int b) {
ll sol = use_machine({kA, a, kB, b});
m[a] = (sol >> 1) ^ kVal;
m[b] = (sol & 1) ^ kVal;
}
int count_mushrooms(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
vector<ll> m(n, 0);
m[0] = 1;
ll sol01 = use_machine({0, 1});
ll sol02;
if (n <= 2) {
if (sol01 == 0) m[1] = 1;
goto end; // Hello
}
sol02 = use_machine({0, 2});
if (sol01 == 0) m[1] = 1;
if (sol02 == 0) m[2] = 1;
if (sol01 == 0) {
kVal = 1;
kA = 0; kB = 1;
}
else if (sol02 == 0) {
kVal = 1;
kA = 0; kB = 2;
}
else {
kVal = 0;
kA = 1; kB = 2;
}
for (ll i = 3; i < n-1; i += 2) {
get(m, i, i+1);
}
if (!(n & 1)) {
get(m, n-2, n-1);
}
end:
ll res = 0;
for (auto &e : m) {
res += e;
}
return res;
}
#ifndef ONLINE_JUDGE
#include "grader.cpp"
#endif
Compilation message
/usr/bin/ld: /tmp/ccoIw7wi.o: in function `use_machine(std::vector<int, std::allocator<int> >)':
stub.cpp:(.text+0x150): multiple definition of `use_machine(std::vector<int, std::allocator<int> >)'; /tmp/cch4NwXe.o:mushrooms.cpp:(.text+0x150): first defined here
/usr/bin/ld: /tmp/ccoIw7wi.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cch4NwXe.o:mushrooms.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status