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<vector<int>> ans(25, vector<int>(n + 1));
for (int i = 0; i <= 24; i++){
// cout << i << " ";
if (i == 0){
int bit = 12;
// cout << bit << " ";
ans[i][0] = 0;
for (int j = 1; j <= n; j++){
ans[i][j] = 1 + (j >> bit & 1);
}
} else if (i % 4 == 1 || i % 4 == 2){
int bit = 12 - (i - 1) / 2;
// cout << bit << " ";
ans[i][0] = 1;
for (int j = 1; j <= n; j++){
int a = (i % 4 == 2);
int b = j >> bit & 1;
if (a > b) ans[i][j] = -2;
else if (a < b) ans[i][j] = -1;
else {
int holy = bit - 1;
int x = i + 1;
if (i % 4 == 1) x++;
if (holy == 0){
if (j >> holy & 1) ans[i][j] = -1;
else ans[i][j] = -2;
}
else
ans[i][j] = x + (j >> holy & 1);
}
}
} else {
int bit = 12 - (i - 1) / 2;
// cout << bit << " ";
ans[i][0] = 0;
for (int j = 1; j <= n; j++){
int b = (i % 4 == 0);
int a = j >> bit & 1;
if (a > b) ans[i][j] = -2;
else if (a < b) ans[i][j] = -1;
else {
int holy = bit - 1;
int x = i + 1;
if (i % 4 == 3) x++;
if (holy == 0){
if (j >> holy & 1) ans[i][j] = -2;
else ans[i][j] = -1;
}
else
ans[i][j] = x + (j >> holy & 1);
}
}
}
// for (int j = 0; j <= n; j++){
// cout << ans[i][j] << " \n"[j == n];
// }
}
for (auto &x : ans) for (auto &y : x) if (y > 26) y = 0;
// for (auto x : ans){
// for (auto y : x ) cout << y << " ";
// cout << "\n";
// }
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |