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;
vector<int> odp;
void build(int l, int p, int n){
if (l==p)return;
string s;
for (int i = 0; i<n; i++)s+='1';
for (int i = l; i<=p; i++){
s[i]='0';
}
int md=(l+p)/2;
for (int i = l; i<=md; i++){
s[i]='1';
add_element(s);
s[i]='0';
}
build(l,md,n);
build(md+1,p,n);
}
void reconstruct(int l, int p, int n, vector<int> podz){
if (l==p){
odp[podz[0]]=l;
return;
}
string s;
for (int i = 0; i<n; i++)s+='1';
for (auto u : podz)s[u]='0';
vector<int> lewo,prawo;
for (auto u : podz){
s[u]='1';
if (check_element(s))lewo.push_back(u);
else prawo.push_back(u);
s[u]='0';
}
reconstruct(l,(l+p)/2,n,lewo);
reconstruct((l+p)/2+1,p,n,prawo);
}
vector<int> restore_permutation(int n, int w, int r){
odp.resize(n);
build(0,n-1,n);
compile_set();
vector<int> wszystko;
for (int i = 0; i<n; i++)wszystko.push_back(i);
reconstruct(0,n-1,n,wszystko);
return odp;
}
# | 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... |