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 = 3, P = 8, x = 24;
int b[P + 2];
vector<vector<int>> devise_strategy(int N)
{
b[0] = b[1] = 1;
for (int i = 2; i <= P + 1; i++)
b[i] = b[i - 1] * B;
vector<vector<int>> sol(x + 1);
int idx = -2, bag = 1;
for (int i = P + 1; i >= 1; i--, idx += 3, bag ^= 3)
{
for (int j = max(0, idx); j < idx + 3; j++)
{
int bit = (3 - j % 3) % 3;
sol[j].emplace_back(bag - 1);
for (int k = 1; k <= N; k++)
{
int cur = k / b[i] % 3, nxt = k / b[i - 1] % 3;
if (i == 1)
{
if (cur < bit)
sol[j].emplace_back(-bag);
else
sol[j].emplace_back(-(bag ^ 3));
}
else
{
if (cur < bit)
sol[j].emplace_back(-bag);
else if(cur == bit)
sol[j].emplace_back(idx + 5 - nxt);
else
sol[j].emplace_back(-(bag ^ 3));
}
}
}
}
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... |