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;
using ll = long long;
using arr = array<int, 2>;
using arrr = array<int, 3>;
// Bruker tretalls systemet
std::vector<std::vector<int>> devise_strategy(int n) {
int x = 22, s = x + 1;
vector<vector<int>> output(s, vector<int>(n + 1));
// Open bag A
output[0][0] = 0;
for (int j = 1; j <= n; j++)
{
output[0][j] = 6 * 3 + 2 + (j / (int)pow(3, 7));
// cout << output[0][j] << "\n";
}
for (int y = 0; y < 7; y++ )
{
for (int i = 2 + y * 3; i <= 4 + y * 3; i++)
{
output[i][0] = ((y + 1) & 1);
for (int j = 1; j <= n; j++)
{
if (y * 3 + 2 + ((j % (int)pow(3, y + 2)) / (int)pow(3, y + 1)) == i)
{
if (y != 0)
{
output[i][j] = (y - 1) * 3 + 2 + ((j % (int)pow(3, y + 1)) / (int)pow(3, y));
} else {
if ((y - 1) * 3 + 2 + ((j % (int)pow(3, y + 1)) / (int)pow(3, y)) == -1) output[i][j] = - 1 - output[i][0];
else if ((y - 1) * 3 + 2 + ((j % (int)pow(3, y + 1)) / (int)pow(3, y)) == 1) output[i][j] = - 1 - (1 ^ output[i][0]);
else output[i][j] = 1;
}
} else if (i > y * 3 + 2 + ((j % (int)pow(3, y + 2)) / (int)pow(3, y + 1)))
{
output[i][j] = -1 - output[i][0];
} else {
output[i][j] = -1 - (1 ^ output[i][0]);
}
}
}
}
// Handle state 1
output[1][0] = 0;
for (int i = 1; i <= n; i++)
{
if (i % 3 == 0) output[1][i] = -1;
else if (i % 3 == 2) output[1][i] = -2;
else output[1][i] = 0;
}
// State 1 and state 3 leads only to victory or loss
// Can therefore be spared
// for (int i = 1; i <= 3; i++)
// {
// output[i][0] = 1;
// for (int j = 1; j <= n; j++)
// {
// if (j % 3 > i % 3)
// {
// output[i][j] = -2;
// } else if (j % 3 < i % 3)
// {
// output[i][j] = -1;
// } else {
// output[i][j] = 0;
// }
// }
// }
return output;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |