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;
int n;
std::vector<int> res;
void gen_rec(int l, int r){
if(l+1==r) return;
string s(n,'0');
for(int i=l; i<r; i++) s[i]='1';
int mid=(l+r)/2;
for(int i=l; i<mid; i++){
s[i]='0';
add_element(s);
s[i]='1';
}
gen_rec(l,mid);
gen_rec(mid,r);
}
void gen_res(int l, int r, set<int> st){
if(l+1==r){
res[*begin(st)]=l;
return;
}
string s(n, '0');
for(auto i:st) s[i]='1';
set<int> s1,s2;
for(auto i:st) {
s[i]='0';
bool t=check_element(s);
s[i]='1';
if(t) s1.insert(i);
else s2.insert(i);
}
int mid=(l+r)/2;
gen_res(l,mid,s1);
gen_res(mid,r,s2);
}
std::vector<int> restore_permutation(int N, int w, int r) {
n=N;
res.resize(n);
gen_rec(0,n);
compile_set();
set<int> st;
for(int i=0; i<n; i++) st.insert(i);
gen_res(0,n,st);
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... |