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> ret;
void build (int l, int r) {
if (l == r) return;
string go = string(n,'0');
for (int i = l; i <= r; i++) go[i] = '1';
int mid = (l + r) / 2;
for (int i = l; i <= mid; i++) {
go[i] = '0';
add_element(go);
go[i] = '1';
}
build(l,mid); build(mid+1,r);
}
void solve (int l, int r, vector<int> &wot) {
if (l == r) return (void) (ret[l] = wot[0]);
vector<int> wotL, wotR;
string go = string(n,'0');
for (int i : wot) go[i] = '1';
for (int i : wot) {
go[i] = '0';
if (check_element(go)) wotL.push_back(i);
else wotR.push_back(i);
go[i] = '1';
}
int mid = (l + r) / 2;
solve(l,mid,wotL); solve(mid+1,r,wotR);
}
vector<int> restore_permutation (int N, int w, int r) {
n=N;
vector<int> go(n); iota(go.begin(),go.end(),0); ret.resize(n);
build(0,n-1);
compile_set();
solve(0,n-1,go);
return ret;
}
# | 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... |