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 "messy.h"
#include <bits/stdc++.h>
#ifdef ALE
#include "grader.cpp"
#endif
using namespace std;
/*
add_element("0");
compile_set();
check_element("0");
*/
int N;
vector<int> ans;
void add(int l, int r){
if(l==r)return;
int m=(l+r)/2;
string s(N,'1');
for(int i=l;i<=r;i++)s[i]='0';
for(int i=l;i<=m;i++){
s[i]='1';
add_element(s);
s[i]='0';
}
add(l,m);
add(m+1,r);
}
void search(int l, int r, vector<int> a){
if(l==r){
ans[a[0]]=l;
return;
}
int m=(l+r)/2;
string s(N,'1');
for(int x:a)s[x]='0';
vector<int> dx,sx;
for(int x:a){
s[x]='1';
if(check_element(s))
sx.push_back(x);
else dx.push_back(x);
s[x]='0';
}
search(l,m,sx);
search(m+1,r,dx);
}
vector<int> restore_permutation(int n, int w, int r) {
N=n;
ans.resize(n);
add(0,N-1);
compile_set();
vector<int> a(N);
iota(a.begin(),a.end(),0);
search(0,N-1,a);
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... |