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;
vector<int>res;
string ers;
void pors(int l,int r){
if(l==r){
return ;
}
for(int i=l;i<=r;i++){
ers[i]='1';
}
for(int i=l;i<=((r+l)>>1);i++){
ers[i]='0';
add_element(ers);
ers[i]='1';
}
for(int i=l;i<=r;i++){
ers[i]='0';
}
pors(l,(r+l)/2);
pors((l+r)/2+1,r);
}
void javab(vector<int>e,int l,int r){
// cout<<l<<" "<<r<<" "<<(int)e.size()<<endl;
if(l==r){
res[e[0]]=l;
return ;
}
vector<int>chap,rast;
for(auto x:e){
ers[x]='1';
}
for(auto x:e){
ers[x]='0';
if(check_element(ers)){
chap.push_back(x);
}else{
rast.push_back(x);
}
ers[x]='1';
}
for(auto x:e){
ers[x]='0';
}
javab(chap,l,(l+r)>>1);
javab(rast,((l+r)>>1)+1,r);
}
std::vector<int> restore_permutation(int n, int w, int r) {
res.resize(n);
ers.resize(n);
pors(0,n-1);
//add_element("0");
compile_set();
//check_element("0");
vector<int>pars;
for(int i=0;i<n;i++){
pars.push_back(i);
}
javab(pars,0,n-1);
return res;
}
# | 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... |