This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prison.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
const int B = 2;
int bag[30], win[30];
vector<pii> spaces[30];
vector<vector<int>> devise_strategy(int N)
{
vector<vector<int>> sol;
bag[0] = 1;
spaces[0] = {pii(1, N)};
int x = 0;
for (int j = 0; j <= x; j++)
{
sol.emplace_back(vector<int>(N + 1, -(bag[j] ^ win[j])));
sol[j][0] = bag[j] - 1;
for (auto [l, r] : spaces[j])
{
sol[j][l] = -bag[j];
sol[j][r] = -(bag[j] ^ 3);
l++, r--;
if (r < l)
continue;
int h = (l + r) / 2;
int p = (j + 1) / 2 * 2 + 1;
bag[p] = bag[p + 1] = bag[j] ^ 3;
win[p] = 3, win[p + 1] = 0;
if (l == r)
{
sol[j][l] = p;
spaces[p].emplace_back(pii(l, r)), x = max(x, p);
}
else
{
spaces[p].emplace_back(pii(l, h));
for (int k = l; k <= h; k++)
sol[j][k] = p;
spaces[p + 1].emplace_back(pii(h + 1, r));
for (int k = h + 1; k <= r; k++)
sol[j][k] = p + 1;
x = max(x, p + 1);
}
}
}
cerr << x << '\n';
return sol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |