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>
using namespace std;
vector<int> restore_permutation(int N, int W, int R) {
int B = __lg(N);
for(int i = 0; i < B; ++i) {
string S(N, '0');
for(int j = 0; j <= i; ++j) {
S[j] = '1';
}
add_element(S);
}
for(int i = B - 1; i >= 0; --i) {
string S(N, '1');
S[B - i - 1] = '0';
for(int j = B; j < N; ++j) {
if(j % (1 << (i + 1)) < (1 << i)) {
S[j] = '0';
add_element(S);
S[j] = '1';
}
}
}
compile_set();
vector<int> P(N, -1);
for(int i = 0; i < B; ++i) {
string S(N, '0');
for(int j = 0; j < i; ++j) S[P[j]] = '1';
for(int j = 0; j < N; ++j) {
if(S[j] == '1') continue;
S[j] = '1';
if(!check_element(S)) {
S[j] = '0';
continue;
}
P[i] = j;
break;
}
if (P[i] == -1) {
while (1) {
}
}
}
string og(N, '0');
for(int i = 0; i < B; ++i) og[P[i]] = '1';
for(int i = 0; i < N; ++i) {
if (og[i] == '1') continue;
int k = 0;
string S(N, '1');
S[i] = '0';
for(int j = 0; j < B; ++j) {
S[P[j]] = '0';
if (!check_element(S)) {
k += 1 << (B - j - 1);
}
S[P[j]] = '1';
}
P[k] = i;
}
vector<int> ans(N);
for(int i = 0; i < N; ++i) {
ans[P[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... |