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;
#define bit(x, i) (((x) >> (i)) & 1)
vector<vector<int>> devise_strategy(int N) {
int X = 39;
vector<vector<int>> s(X + 1, vector<int>(N + 1, 0));
s[0][0] = 0;
for (int i = 1; i <= N; i++){
s[0][i] = 37;
}
for (int i = 1; i <= X; i++){
int b = (i - 1) / 3;
int r = (i - 1) % 3;
if (r == 0){ /// didn't open A
s[i][0] = 0;
for (int j = 1; j <= N; j++){
s[i][j] = b * 3 + 2 + bit(j, b);
}
} else if (r == 1){ /// opened A, bit was 0
s[i][0] = 1;
for (int j = 1; j <= N; j++){
if (bit(j, b)){
s[i][j] = -1;
} else {
s[i][j] = (b - 1) * 3 + 1;
}
}
} else if (r == 2){ /// opened A, was 1
s[i][0] = 1;
for (int j = 1; j <= N; j++){
if (!bit(j, b)){
s[i][j] = -2;
} else {
s[i][j] = (b - 1) * 3 + 1;
}
}
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |