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 <vector>
#include<string>
#include "messy.h"
using namespace std;
int N;
vector<int> Ans;
void add(int l, int r) {
if (l == r) {return;}
string s;
int mid = (l + r) >> 1;
for (int i=0; i<N; i++) {
if (l <= i && i <= r) {
s.push_back('0');
} else {
s.push_back('1');
}
}
for (int i=l; i<=mid; i++) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(l, mid);
add(mid+1,r);
}
void slv(int l, int r, vector<bool> Not) {
if (l == r) {
for (int i=0; i<N; i++) {
if (!Not[i]) {Ans[i]=l;}
}
} else {
string s;
vector<bool> NotL=Not, NotR=Not;
int mid = (l + r) >> 1;
for (int i=0; i<N; i++) {
if (Not[i]) {
s.push_back('1');
} else {
s.push_back('0');
}
}
for (int i=0; i<N; i++) {
if (!Not[i]) {
s[i] = '1';
if (check_element(s)) {
NotR[i] = true;
} else {
NotL[i] = true;
}
s[i] = '0';
}
}
slv(l, mid, NotL);
slv(mid+1, r, NotR);
}
}
vector<int> restore_permutation(int n, int w, int r) {
N = n;
vector<bool> Not;
for (int i=0; i<N; i++) {
Not.push_back(0);
Ans.push_back(0);
}
add(0, N-1);
compile_set();
slv(0, N-1, Not);
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... |