# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829253 | caganyanmaz | Prisoner Challenge (IOI22_prison) | C++17 | 9 ms | 1108 KiB |
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>
#include "prison.h"
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
#include <vector>
using namespace std;
int x = 23;
vector<vector<int>> devise_strategy(int N)
{
int n = N;
vector<vector<int>> v(x+1, vector<int>(n+1));
v[0][0] = 0;
for (int i = 1; i <= n; i++)
{
v[0][i] = 21+(i>>(12));
}
for (int i = 12; i >= 3; i--)
{
int a = (i-2) * 2 + 1;
int current = (i+1)&1; // 0 a, 1 b
int rmask = (1<<i) - 1;
debug(i, current, rmask);
v[a][0] = v[a+1][0] = current;
for (int j = 1; j <= n; j++)
{
int draw;
if (j&(1<<i))
{
v[a][j] = -2 + current;
draw = a+1;
}
else
{
draw = a;
v[a+1][j] = - 1 - current;
}
if ((j&rmask) == 0)
v[draw][j] = - 1 - current;
else if ((j&rmask) == rmask)
v[draw][j] = -2+current;
else
v[draw][j] = a-2+((j>>(i-1))&1);
}
}
v[1][0] = v[2][0] = 1;
for (int i = 1; i <= n; i++)
{
int draw;
if (i&4)
{
v[1][i] = -1;
if ((i&3) >= 2)
v[2][i] = -1;
else if ((i&3) == 0)
v[2][i] = -2;
else
v[2][i] = 23;
}
else
{
v[2][i] = -2;
if ((i&3) <= 1)
v[1][i] = -2;
else if ((i&3) == 3)
v[1][i] = -1;
else
v[1][i] = 23;
}
}
v[23][0] = 0;
for (int i = 1; i <= n; i++)
{
if (i&2)
v[23][i] = -2;
else
v[23][i] = -1;
}
return v;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |