이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n;
vector<int> ans_r;
string ts(int k) {
string s = "";
for (int i = 0; i < n; i++) {
s.pb(!!(k & (1 << i)) + '0');
}
return s;
}
void dnc(int in_l, int in_r, vector<int> out) {
if (in_l == in_r) {
ans_r[in_l] = out[0];
return;
}
vector<int> fh_out, sh_out;
int cur = 0;
for (int i = 0; i < n; i++) {
if (!binary_search(out.begin(), out.end(), i)) cur |= (1 << i);
}
for (int i = 0; i < (int)out.size(); i++) {
cur ^= (1 << out[i]);
if (check_element(ts(cur))) {
fh_out.pb(out[i]);
} else {
sh_out.pb(out[i]);
}
cur ^= (1 << out[i]);
}
int in_m = (in_l + in_r) / 2;
dnc(in_l, in_m, fh_out);
dnc(in_m + 1, in_r, sh_out);
}
vector<int> restore_permutation(int n, int w, int r) {
::n = n;
for (int i = 1; (1 << i) <= n; i++) {
for (int j = 0; j < n; j += (1 << i)) {
int base = ((1 << n) - 1);
for (int k = j; k < j + (1 << i); k++) {
base ^= (1 << k);
}
for (int k = j; k < j + (1 << (i - 1)); k++) {
base ^= (1 << k);
add_element(ts(base));
base ^= (1 << k);
}
}
}
compile_set();
vector<int> all;
for (int i = 0; i < n; i++) all.pb(i);
ans_r.resize(n);
dnc(0, n - 1, all);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[ans_r[i]] = i;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |