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;
vector<vector<int>> devise_strategy(int N) {
vector<int> seq(13, 2);
vector<vector<int>> strategy(27, vector<int>(N + 1));
for (int i = 0; i < 27; i++) {
int bit = (i + 1) / 2;
int player = (bit % 2 == 0 ? 0 : 1);
strategy[i][0] = player;
for (int j = 1; j <= N; j++) {
if (i >= 25) {
strategy[i][j] = 0;
continue;
}
if (player == 0) {
if (i == 0) {
strategy[i][j] = 1 + (j >> (12 - bit) & 1);
} else {
int he = 1 - (i % 2);
int me = (j >> (12 - (bit - 1)) & 1);
int my_bag = (player == 0 ? 1 : 2);
int his_bag = (my_bag ^ 1 ^ 2);
strategy[i][j] = (me < he ? -my_bag : (me > he ? -his_bag : i + (i % 2) + 1 + (j >> (12 - bit) & 1)));
}
} else {
assert(i > 0);
int he = 1 - (i % 2);
int me = (j >> (12 - (bit - 1)) & 1);
int my_bag = (player == 0 ? 1 : 2);
int his_bag = (my_bag ^ 1 ^ 2);
strategy[i][j] = (me < he ? -my_bag : (me > he ? -his_bag : i + (i % 2) + 1 + (j >> (12 - bit) & 1)));
}
}
}
return strategy;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |