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 <bits/stdc++.h>
#include "messy.h"
using namespace std;
vector<int> a;
int n;
void solve(int l, int r, set<int> st) {
if (l == r) {
a[l] = *st.begin();
return;
}
string s(n, '0');
for (int i = 0; i < n; i++) {
if (!st.count(i)) {
s[i] = '1';
}
}
set<int> tmp_l, tmp_r;
for (auto& x : st) {
s[x] = '1';
if (check_element(s)) {
tmp_l.insert(x);
} else {
tmp_r.insert(x);
}
s[x] = '0';
}
solve(l, (l + r) / 2, tmp_l);
solve((l + r) / 2 + 1, r, tmp_r);
}
vector<int> restore_permutation(int _n, int w, int r) {
n = _n;
for (int k = 2; k <= n; k += k) {
for (int i = 0; i + k - 1 < n; i += k) {
string s(n, '1');
for (int j = i; j < i + k; j++) {
s[j] = '0';
}
for (int j = i; j < i + k / 2; j++) {
s[j] = '1';
add_element(s);
s[j] = '0';
}
}
}
compile_set();
a.assign(n, -1);
set<int> st;
for (int i = 0; i < n; i++) {
st.insert(i);
}
solve(0, n - 1, st);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[a[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... |