#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef long long ll;
int count_mushrooms(int N)
{
vector<int> index(N);
for (int i = 0; i < N; i++)
index[i] = i;
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef long long ll;
int count_mushrooms(int N)
{
vector<int> index(N);
for (int i = 0; i < N; i++)
index[i] = i;
//mt19937 mt(time(NULL));
//shuffle(index.begin() + 1, index.end(), mt);
int ans = 1;
for (int i = 1; i < N - 3; i += 4)
{
int a = index[i], b = index[i+1], c = index[i+2], d = index[i+3];
int res = use_machine( { a, b, 0, c, d } );
if (res == 0)
{
ans += 4;
}
else if (res == 1)
{
int t = use_machine({0, a, c, b, d});
if (t == 1 || t == 2) ans += 3;
else ans += 2;
}
else if (res == 2)
{
int t = use_machine({c, a, 0, d, b});
if (t == 1) ans += 3;
else if (t == 4) ans += 2;
else if (t == 3) ans++;
}
else if (res == 3)
{
int t = use_machine({a, b, c, d});
if (t == 3) ans += 2;
else if (t == 1) ans++;
}
else
{
ans += 2;
}
}
for (int i = 0; i < (N - 1) % 4; i++)
{
if (!use_machine({0, index[N - 1 - i]})) ans++;
}
return ans;
}
//mt19937 mt(time(NULL));
//shuffle(index.begin() + 1, index.end(), mt);
int ans = 1;
for (int i = 1; i < N - 3; i += 4)
{
int a = index[i], b = index[i+1], c = index[i+2], d = index[i+3];
int res = use_machine( { a, b, 0, c, d } );
if (res == 0)
{
ans += 4;
}
else if (res == 1)
{
int t = use_machine({0, a, c, b, d});
if (t == 1 || t == 2) ans += 3;
else ans += 2;
}
else if (res == 2)
{
int t = use_machine({c, a, 0, d, b});
if (t == 1) ans += 3;
else if (t == 4) ans += 2;
else if (t == 3) ans++;
}
else if (res == 3)
{
int t = use_machine({a, b, c, d});
if (t == 3) ans += 2;
else if (t == 1) ans++;
}
else
{
ans += 2;
}
}
for (int i = 0; i < (N - 1) % 4; i++)
{
if (!use_machine({0, index[N - 1 - i]})) ans++;
}
return ans;
}
Compilation message
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:19:1: error: a function-definition is not allowed here before '{' token
19 | {
| ^