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 <bits/stdc++.h>
using namespace std;
constexpr static int LIM = 32;
vector<vector<int>> res;
void evaluate_a(int a, int n)
{
res[a][0] = 0;
int shft = 2 * (a / 5 - 1);
for (int i = 1; i <= n; i++)
{
int oo = (i >> shft) & 3;
res[a][i] = a - 5 + oo + 1;
}
}
void evaluate_b(int a, int n)
{
res[a][0] = 1;
int shft = 2 * (a / 5);
for (int i = 1; i <= n; i++)
{
int oo = (i >> shft) & 3;
if (oo + 1 > (a % 5))
res[a][i] = -1;
else if (oo + 1 < (a % 5))
res[a][i] = -2;
else
res[a][i] = a - (a%5);
}
}
void evaluate(int a, int n)
{
if (a % 5)
evaluate_b(a, n);
else
evaluate_a(a, n);
}
vector<vector<int>> devise_strategy(int n)
{
res = vector<vector<int>>(LIM + 1, vector<int>(n+1));
res[0][1] = 0;
for (int i = 1; i <= n; i++)
res[0][1] = 32 - (i>>12);
for (int i = 31; i <= 32; i++)
{
res[i][0] = 1;
for (int j = 1; j <= n; j++)
{
if ((i&1) > (j>>12))
res[i][j] = -2;
else if ((i&1) < (j>>12))
res[i][j] = -1;
else
res[i][j] = 30;
}
}
for (int i = 1; i <= 30; i++)
evaluate(i, n);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |