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 <iostream>
#include <vector>
#include "messy.h"
using namespace std;
string sbeg, s1, cur;
vector <int> curv;
vector <int> ans, perm;
void add_el(int l, int r) {
if (l>=r) return;
int mid=(l+r)/2;
s1=sbeg;
for (int i=l;i<=r;i++) s1[i]='0';
for (int i=l;i<=mid;i++) {
cur=s1;
cur[i]='1';
add_element(cur);
}
add_el(l,mid);
add_el(mid+1,r);
}
void check_el(int l, int r, vector <int> v) {
if (l==r) perm[l]=v[0];
if (l>=r) return;
vector <int> lef, ri;
s1=sbeg;
for (auto i:v) s1[i]='0';
for (auto i:v) {
cur=s1;
cur[i]='1';
if (check_element(cur)) {
lef.push_back(i);
} else {
ri.push_back(i);
}
}
int mid=(l+r)/2;
check_el(l,mid,lef);
check_el(mid+1,r,ri);
}
vector<int> restore_permutation(int N, int w, int r) {
int n=N;
ans.resize(n); perm.resize(n);
for (int i=0;i<n;i++) {
sbeg+='1';
cur+='1';
}
add_el(0,n-1);
compile_set();
for (int i=0;i<n;i++) curv.push_back(i);
check_el(0,n-1,curv);
for (int i=0;i<n;i++) ans[perm[i]]=i;
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... |