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 pb push_back
int n;
vector<int> ans;
void fsolve(int l, int r){
if(r-l==1) return;
int m=(l+r)>>1;
string s;
for(int i=0; i<n; i++){
if(i<l || i>=r) s.pb('1');
else s.pb('0');
}
for(int i=l; i<m; i++){
s[i]='1';
add_element(s);
s[i]='0';
}
fsolve(l,m);
fsolve(m,r);
}
void ssolve(int l, int r, vector<int> t){
if(r-l==1){
ans[t[0]]=l;
return;
}
int m=(l+r)>>1;
vector<int> v1,v2;
string s;
for(int i=0; i<n; i++) s.pb('1');
for(int i : t) s[i]='0';
for(int i : t){
s[i]='1';
if(check_element(s)){
v1.pb(i);
}else{
v2.pb(i);
}
s[i]='0';
}
ssolve(l,m,v1);
ssolve(m,r,v2);
}
vector<int> restore_permutation(int n, int w, int r) {
::n=n;
ans.resize(n);
vector<int> t;
for(int i=0; i<n; i++) t.pb(i);
fsolve(0,n);
compile_set();
ssolve(0,n,t);
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... |