이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include<bits/stdc++.h>
using namespace std;
#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 1e6;
vector<vector<int>> devise_strategy(int n) {
int pw[8];
pw[0] = 1;
for (int i = 1; i < 8; i++) pw[i] = pw[i - 1] * 3;
vector<int> f(31), g(40);
int j = 0;
for (int i = 0; i <= 30; i++, j++) {
if (j == 2 || j == 4) j++;
f[i] = j;
g[j] = i;
}
vector<vector<int>> ans;
for (int z = 0; z <= 30; z++) {
int x = f[z];
if (!x) {
vector<int> s = {0};
for (int i = 1; i <= n; i++) {
int v = (i / pw[7]) % 3 + 1;
s.push_back(g[7 * 4 + v + 1]);
}
ans.push_back(s);
continue;
}
int v = x - 1;
if (v % 4) {
vector<int> s = {1};
int b = v / 4, is = v % 4 - 1;
for (int i = 1; i <= n; i++) {
int y = (i / pw[b]) % 3;
if (is < y) s.push_back(-1);
else if (is > y) s.push_back(-2);
else {
if (!b) s.push_back(-1);
else s.push_back(g[(b - 1) * 4 + 1]);
}
}
ans.push_back(s);
}else {
vector<int> s = {0};
int b = v / 4;
for (int i = 1; i <= n; i++) {
int y = (i / pw[b]) % 3 + 1;
if (!b && y == 1) s.push_back(-1);
else if (!b && y == 3) s.push_back(-2);
else s.push_back(g[b * 4 + y + 1]);
}
ans.push_back(s);
}
}
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... |