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"
using namespace std;
vector<vector<int>> devise_strategy(int n)
{
vector <vector<int>> res;
for(int i = 0 ; i <= 24 ; i++)
{
vector <int> vec(n + 1 , 0);
res.push_back(vec);
}
for(int i = 0 ; i <= 24 ; i++)
{
if(i == 0)
{
res[i][0] = 0;
for(int j = 1 ; j <= n ; j++)
res[i][j] = 2 * 11 + ((j >> 12) & 1) + 1;
continue;
}
int bit = (i - 1) / 2;
bit++;
if(bit % 2 == 0)
res[i][0] = 1;
else
res[i][0] = 0;
int val = (i - 1) % 2;
for(int j = 1 ; j <= n ; j++)
{
int v = (j >> bit) & 1;
if(v != val)
{
if(val > v)
{
if(res[i][0] == 0)
res[i][j] = -1;
else
res[i][j] = -2;
}
else
{
if(res[i][0] == 0)
res[i][j] = -2;
else
res[i][j] = -1;
}
}
else
{
if(bit == 0)
continue;
v = (j >> (bit - 1)) & 1;
if(bit == 1)
{
if(v == 1)
res[i][j] = -2;
else
res[i][j] = -1;
continue;
}
res[i][j] = 2 * (bit - 2) + 1 + v;
}
}
}
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... |