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>
#include <vector>
using namespace std;
std::vector<int> restore_permutation(int n, int w, int r) {
function<void(int, int)> prep = [&](int l, int r) {
// [l, r)
if (l + 1 == r) return;
string base(n, '0');
for (int i = 0; i < l; i++) base[i] = '1';
for (int i = r; i < n; i++) base[i] = '1';
int m = l + r >> 1;
for (int i = l; i < m; i++) {
string tmp = base;
tmp[i] = '1';
add_element(tmp);
}
prep(l, m);
prep(m, r);
};
vector<int> ans(n);
function<void(int, int, vector<int>)> guess = [&](int l, int r, vector<int> candidates) {
// [l, r)
if (l + 1 == r) return void(ans[candidates[0]] = l);
string base(n, '1');
for (int i : candidates) base[i] = '0';
vector<int> cl, cr;
for (int i : candidates) {
string tmp = base;
tmp[i] = '1';
vector<int>& which = check_element(tmp) ? cl : cr;
which.emplace_back(i);
}
int m = l + r >> 1;
guess(l, m, cl);
guess(m, r, cr);
};
prep(0, n);
compile_set();
vector<int> id(n);
iota(id.begin(), id.end(), 0);
guess(0, n, id);
return ans;
}
Compilation message (stderr)
messy.cpp: In lambda function:
messy.cpp:15:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
15 | int m = l + r >> 1;
| ~~^~~
messy.cpp: In lambda function:
messy.cpp:37:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
37 | int m = l + r >> 1;
| ~~^~~
# | 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... |