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;
int x = 14;
vector<vector<int>> devise_strategy(int N) {
vector <vector <int> > rs (2 * x + 1, vector <int> (N + 1, 0));
rs[0][0] = 0;
for (int i = 1; i <= N; i++){
rs[0][i] = ((i & (1 << x)) ? 2: 1);
}
for (int i = 1, bit = x; i <= 2 * x; i++){
int open = ((i + 1) / 2) % 2;
rs[i][0] = open;
// cout << i << " " << bit << "\n";
if (i % 2 == 1) { // bit unset
for (int j = 1; j <= N; j++){
if (j & (1 << (bit - 1))){
rs[i][j] = -(!open) - 1;
}
else {
if (j & (1 << (bit - 2))) {
rs[i][j] = i + 3;
}
else rs[i][j] = i + 2;
}
}
}
else {
for (int j = 1; j <= N; j++){ // bit set
// clog << "> " << j << "\n";
if (j & (1 << (bit - 1))) {
if (j & (1 << (bit - 2))) {
rs[i][j] = i + 2;
}
else rs[i][j] = i + 1;
}
else {
rs[i][j] = -open - 1;
}
}
bit--;
}
}
for (int i = 0; i <= 2 * x; i++){
for (int j = 0; j < N + 1; j++){
if (rs[i][j] > 2 * x) rs[i][j] = -1;
}
// cout << "\n";
}
return rs;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |