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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
int ng;
void build(int l, int r){
if(l == r)return;
string s(ng, '1');
for(int i=l;i<=r;i++){
s[i] = '0';
}int mid = (l+r)>>1;
for(int i=l;i<=mid;i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
build(l, mid);
build(mid+1, r);
}
void find_ans(int l, int r, vector<int> v, vector<int> &ans){
if(l == r){
ans[v[0]] = l;
return;
}string s(ng, '1');
for(auto x : v)s[x] = '0';
vector<int> L, R;
for(int i=l;i<=r;i++){
s[v[i-l]] = '1';
if(check_element(s)){
L.push_back(v[i-l]);
}else {
R.push_back(v[i-l]);
}s[v[i-l]] = '0';
}
int mid = (l+r)>>1;
find_ans(l, mid, L, ans);
find_ans(mid+1, r,R,ans);
}
vector<int> restore_permutation(int N, int w, int r) {
ng = N;
build(0, ng-1);
compile_set();
vector<int> ans(ng);
vector<int> v;
for(int i=0;i<ng;i++)v.push_back(i);
find_ans(0, ng-1, v, ans);
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... |