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;
int n;
vector<int> p;
void add(int l, int r){
if (l == r) return;
int m = (l + r) >> 1;
string s(n, '1');
for (int i = l; i <= r; i++) s[i] = '0';
for (int i = l; i <= m; i++) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(l, m);
add(m + 1, r);
}
void build(int l, int r, vector<int> v){
if (l == r){
p[v[0]] = l;
return;
}
vector<int> lf, rg;
string s(n, '1');
for (int i : v) s[i] = '0';
for (int i : v){
s[i] = '1';
if (check_element(s)){
lf.push_back(i);
} else rg.push_back(i);
s[i] = '0';
}
int m = (l + r) >> 1;
build(l, m, lf);
build(m + 1, r, rg);
}
vector<int> restore_permutation(int _n, int w, int r) {
n = _n;
p.resize(n);
add(0, n - 1);
compile_set();
vector<int> v(n);
for (int i = 0; i < n; i++) v[i] = i;
build(0, n - 1, v);
return p;
}
# | 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... |