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 <vector>
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
void dfs1(int l,int r,int n){
if (l==r) return;
int mid=(l+r)/2;
for (int i=l; i<=mid; i++){
string s="";
for (int j=0; j<n; j++){
if (j<l||j>r||j==i) s+='1';
else s+='0';
}
add_element(s);
}
dfs1(l,mid,n);
dfs1(mid+1,r,n);
}
vector <int> ans;
void dfs2(int l,int r,vector <int> can,int n){
if (can.size()==1){
ans[can[0]]=l;
return;
}
vector <int> lef,rig;
for (int i:can){
string s="";
for (int j=0; j<n; j++) s+='1';
for (int j:can) s[j]='0';
s[i]='1';
if (check_element(s)) lef.push_back(i);
else rig.push_back(i);
}
int mid=(l+r)/2;
dfs2(l,mid,lef,n);
dfs2(mid+1,r,rig,n);
}
vector <int> restore_permutation(int n,int w,int r){
dfs1(0,n-1,n);
compile_set();
vector <int> v;
for (int i=0; i<n; i++) v.push_back(i);
ans.resize(n);
dfs2(0,n-1,v,n);
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... |