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 "grader.cpp"
#include "messy.h"
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
int N,W,R;
vector<int> ans;
void build1(int l, int r){
if(l==r) return;
int md=(l+r)/2;
string s(N,'1');
for(int i=l;i<=r;i++) s[i]='0';
for(int i=l;i<=md;i++){
s[i]='1';
add_element(s);
s[i]='0';
}
build1(l,md);build1(md+1,r);
}
void get(int l, int r, vector<int> v){
if(l==r){
ans[v[0]]=l;return;
}
int md=(l+r)/2;
string s(N,'1');
for(auto it: v) s[it]='0';
vector<int> L,R;
for(auto it: v){
s[it]='1';
if(check_element(s)) L.pb(it);
else R.pb(it);
s[it]='0';
}
get(l,md,L);get(md+1,r,R);
}
vector<int> restore_permutation(int n, int w, int r) {
N=n,W=w,R=r;
ans.resize(N);
build1(0,N-1);
compile_set();
vector<int> v;
for(int i=0;i<n;i++) v.pb(i);
get(0,N-1,v);
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... |