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;
#define FOR(i, a, b) for (int i = a; i < b; i++)
typedef vector<int> vi;
#define pb push_back
int n;
int ind = 0;
void ins(int l, int dep = n) {
if (dep == 1) return;
// cout << l << dep << endl;
string cur;
FOR(i, 0, l) cur += '1';
FOR(i, l, l + dep) cur += '0';
FOR(i, l + dep, n) cur += '1';
FOR(i, l, l + dep/2) {
cur[i] = '1';
add_element(cur);
// cout << cur << endl;
cur[i] = '0';
}
ins(l, dep/2);
ins(l + dep/2, dep/2);
}
vi res;
void solve(vector<int> state) {
if (state.size() == 1) {
res[state[0]] = ind++;
return;
}
// for (auto val: state) {
// cout << val << ' ';
// }
// cout << endl;
string cur;
FOR(i, 0, n) cur += '1';
for (auto val: state) cur[val] = '0';
vector<int> w, wo;
for (auto val: state) {
cur[val] = '1';
// cout << check_element(cur) << endl;
if (check_element(cur)) w.pb(val);
else wo.pb(val);
cur[val] = '0';
}
// return;
solve(w);
solve(wo);
}
vector<int> restore_permutation(int nn, int w, int r) {
n = nn;
ins(0, n);
compile_set();
vi f;
FOR(i, 0, n) f.pb(i);
res.resize(n);
solve(f);
return res;
}
// int main() {
// n = 8;
// ins(0);
// }
# | 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... |