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_all(int l, int r) {
if (l == r) return;
int mid = (l + r) >> 1;
string s(n, '1');
for (int i = l; i <= r; i++) s[i] = '0';
for (int i = l; i <= mid; i++) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
add_all(l, mid);
add_all(mid + 1, r);
}
void solve(int l, int r, vector <int> can) {
if (l == r) {
p[can[0]] = l;
return;
}
int mid = (l + r) >> 1;
string s(n, '1');
vector <int> lft, rgt;
for (int i : can) s[i] = '0';
for (int i : can) {
s[i] = '1';
if (check_element(s) == 1) {
lft.push_back(i);
} else {
rgt.push_back(i);
}
s[i] = '0';
}
solve(l, mid, lft);
solve(mid + 1, r, rgt);
}
vector<int> restore_permutation(int N, int w, int r) {
n = N;
p.resize(n);
add_all(0, n - 1);
compile_set();
vector <int> can(n);
for (int i = 0; i < n; i++) can[i] = i;
solve(0, n - 1, can);
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... |