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"
using namespace std;
vector<int> restore_permutation(int n, int w, int r) {
int k = 31 - __builtin_clz(n);
vector<int> p(n, 0);
auto addSubset = [&](vector<int> subset) {
string s(n, '0');
for (int i : subset) {
s[i] = '1';
}
add_element(s);
};
for (int b = 0; b < k; b++) {
int mask = (1 << b) - 1;
for (int base = 0; base < n; base++) {
if (base >> b & 1) {
vector<int> subset = { base };
for (int aug = 0; aug < n; aug++) {
if ((aug & mask) != (base & mask)) {
subset.push_back(aug);
}
}
addSubset(subset);
}
}
}
compile_set();
auto checkSubset = [&](vector<int> subset) {
string s(n, '0');
for (int i : subset) {
s[i] = '1';
}
return check_element(s);
};
for (int b = 0; b < k; b++) {
int mask = (1 << b) - 1;
for (int i = 0; i < n; i++) { // here tries to infer the 2^b bit of p[i]
vector<int> subset = { i };
for (int j = 0; j < n; j++) {
if ((p[j] & mask) != (p[i] & mask)) {
subset.push_back(j);
}
}
p[i] |= checkSubset(subset) << b;
}
}
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... |