이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(27, vector<int>(n + 1));
for (int i = 0; i <= 26; i++){
if (i == 0){
int bit = 12;
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 / 4);
ans[i][0] = 1;
for (int j = 1; j <= n; j++){
int a = (i % 4) - 1;
int b = j >> bit & 1;
if (a > b) ans[i][j] = -2;
else if (a < b) ans[i][j] = -1;
else {
bit++;
int x = i + 1;
if (i % 4 == 1) x++;
ans[i][j] = x + (j >> bit & 1);
assert(ans[i][j] % 4 == 3 || ans[i][j] % 4 == 0);
}
}
} else {
int bit = 12 - (i + 1) / 4;
ans[i][0] = 0;
for (int j = 1; j <= n; j++){
int b;
if (i % 4 == 0) b = 1;
else b = 0;
int a = j >> bit & 1;
if (a > b) ans[i][j] = -2;
else if (a < b) ans[i][j] = -1;
else {
bit++;
int x = i + 1;
if (i % 4 == 3) x++;
ans[i][j] = x + (j >> bit & 1);
assert(ans[i][j] % 4 == 1 || ans[i][j] % 4 == 2);
}
}
}
}
for (auto &x : ans) for (auto &y : x) if (y > 26) y = 0;
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... |