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;
const int MN=500;
void writ(int l,int r){
if(r-l<2){
return;
}
string s;
int mid=(l+r)/2;
for(int i=0;i<l;i++){
s+='1';
}
for(int i=l;i<r;i++){
s+='0';
}
for(int i=r;i<N;i++){
s+='1';
}
for(int i=l;i<mid;i++){
s[i]='1';
add_element(s);
s[i]='0';
}
writ(l,mid);
writ(mid,r);
}
int p[MN];
void restore(int l,int r,set<int> pos){
string s;
for(int i=0;i<N;i++){
if(pos.count(i)==0){
s+='1';
}
else{
s+='0';
}
}
if(r-l<2){
p[*pos.begin()]=l;
return;
}
set<int> pos1,pos2;
for(int i:pos){
s[i]='1';
if(check_element(s)){
pos1.insert(i);
}
else{
pos2.insert(i);
}
s[i]='0';
}
int mid=(l+r)/2;
restore(l,mid,pos1);
restore(mid,r,pos2);
}
vector<int> restore_permutation(int n, int w, int r) {
N=n;
writ(0,N);
compile_set();
set<int> s;
for(int i=0;i<N;i++){
s.insert(i);
}
restore(0,N,s);
vector<int> v;
for(int i=0;i<n;i++){
v.push_back(p[i]);
}
return v;
}
# | 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... |