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>
using namespace std;
vector<std::vector<int>> devise_strategy(int N)
{
if (N > 1000)
while(true);
vector < vector < int > > strategy;
int maxnum = 30;
strategy.resize(maxnum + 1);
for (int i = 0; i <= maxnum; i ++)
strategy[i].resize(N + 1);
strategy[0][0] = 0;
for (int j = 1; j <= N; j ++)
{
int mask = ((j & (1 << 12)) > 0) * 2 + ((j & (1 << 11)) > 0);
strategy[0][j] = mask + 1;
}
for (int i = 1; i <= maxnum; i ++)
{
if (i == 25)
{
strategy[i][0] = 0;
for (int j = 1; j <= N; j ++)
{
if ((j & 1))
strategy[i][j] = -2;
else
strategy[i][j] = -1;
}
}
else if (i > 25)
{
if (i > 30)
continue;
int dis = i - 25;
int bit1 = 12 - dis * 2;
int bit2 = 11 - dis * 2;
strategy[i][0] = 0;
for (int j = 1; j <= N; j ++)
{
int mask = ((j & (1 << bit1)) > 0) * 2 + ((j & (1 << bit2)) > 0);
strategy[i][j] = dis * 4 + mask + 1;
}
}
else
{
int dis = (i - 1) / 4, mask = (i - 1) % 4;
int bit1 = 12 - dis * 2;
int bit2 = 11 - dis * 2;
///cout << i << " " << bit1 << " " << bit2 << endl;
strategy[i][0] = 1;
for (int j = 1; j <= N; j ++)
{
int new_mask = ((j & (1 << bit1)) > 0) * 2 + ((j & (1 << bit2)) > 0);
///cout << i << " " << j << " " << new_mask << endl;
if (new_mask < mask)
strategy[i][j] = -2;
else if (new_mask > mask)
strategy[i][j] = -1;
else
{
if (dis == 5)
strategy[i][j] = 25;
else
strategy[i][j] = 25 + dis + 1;
}
}
}
/**int type = (i - 1) / 4, bit = (i - type * 13) - 1;
if (type == 2)
{
strategy[i][0] = 0;
bit --;
for (int j = 1; j <= N; j ++)
{
if ((j & (1 << bit)))
strategy[i][j] = get_mask(0, bit + 1);
else
strategy[i][j] = get_mask(1, bit + 1);
}
}
else
{
strategy[i][0] = 1;
for (int j = 1; j <= N; j ++)
{
if ((j & (1 << bit)))
{
if (type == 1)
{
strategy[i][j] = -1;
}
else
strategy[i][j] = get_mask(2, bit + 1);
}
else
{
if (type == 0)
{
strategy[i][j] = -2;
}
else
strategy[i][j] = get_mask(2, bit + 1);
}
}
}*/
}
/**for (int i = 0; i <= 30; i ++, cout << endl)
for (int j = 1; j <= N; j ++)
cout << strategy[i][j] << " ";
cout << endl;*/
return strategy;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |