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;
bool has(int x, int bit) {
return (x >> bit) & 1;
}
vector<vector<int>> devise_strategy(int N) {
vector<vector<int>> s(27, vector<int>(N + 1));
s[0][0] = 0;
for (int j = 1; j <= N; ++j)
s[0][j] = 13 * (has(j, 12) + 1);
for (int i = 1; i <= 26; ++i) {
int u = (i > 13), bit = i - u * 13 - 1;
s[i][0] = (bit + 1) & 1;
for (int j = 1; j <= N; ++j) {
int v = has(j, bit);
if (u != v)
s[i][j] = -2 + (u ? s[i][0] ^ 1 : s[i][0]);
else {
s[i][j] = has(j, bit - 1) * 13 + bit;
}
}
}
/*for (auto it : s) {
for (auto it2 : it)
cout << it2 << ' ';
cout << '\n';
}*/
return s;
}
//3
//1 2
//1 3
//2 1
//2 3
//3 1
//3 2
//-1
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |