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 fastlog(int n) {
return 32 - __builtin_clz(n) - 1;
}
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> p(n);
string empty;
for(int i=0; i<n; i++) empty += '0';
for(int i=1; i<n; i+=2) {
empty[i] = '1';
add_element(empty);
empty[i] = '0';
}
for(int i=1; i<fastlog(n); i++) {
for(int j=0; j<n; j++) {
if((j&(1<<i)) != 0) {
int v = j % (1<<i);
v = (1<<i) - 1 - v;
for(int k=0; k<n; k++) {
if(k % (1<<i) == v % (1<<i)) {
empty[k] = '1';
}
}
empty[j] = '1';
add_element(empty);
for(int k=0; k<n; k++) {
empty[k] = '0';
}
}
}
}
compile_set();
for(int i=0; i<n; i++) {
empty[i] = '1';
if(check_element(empty)) {
p[i]++;
}
empty[i] = '0';
}
for(int i=1; i<fastlog(n); i++) {
for(int j=0; j<n; j++) {
int v = (1<<i) - 1 - p[j];
for(int k=0; k<n; k++) {
if(p[k] % (1<<i) == v % (1<<i)) {
empty[k] = '1';
}
}
empty[j] = '1';
if(check_element(empty)) {
p[j] += (1<<i);
}
for(int k=0; k<n; k++) {
empty[k] = '0';
}
}
}
return p;
}
# | 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... |