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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
namespace subtask_full {
int N, W, R;
vector<int> perm;
void add_elements(int l, int r) {
if (l >= r)
return;
int m = (l + r) >> 1;
string tmp(N, '1');
for (int i = l; i <= r; i++)
tmp[i] = '0';
for (int i = l; i <= m; i++) {
tmp[i] = '1';
add_element(tmp);
tmp[i] = '0';
}
add_elements(l, m);
add_elements(m + 1, r);
}
inline void add_elements() { add_elements(0, N - 1); }
void check_elements(int l, int r, vector<int> vals) {
if (l >= r) {
perm[vals[0]] = r;
return;
}
int m = (l + r) >> 1;
string tmp(N, '1');
for (int i : vals)
tmp[i] = '0';
vector<int> left_vals, right_vals;
for (int v : vals) {
tmp[v] = '1';
if (check_element(tmp))
left_vals.push_back(v);
else
right_vals.push_back(v);
tmp[v] = '0';
}
check_elements(l, m, left_vals);
check_elements(m + 1, r, right_vals);
}
inline void check_elements() {
vector<int> vals(N);
iota(vals.begin(), vals.end(), 0);
perm.resize(N);
check_elements(0, N - 1, vals);
}
vector<int> restore_permutation(int n, int w, int r) {
N = n, W = w, R = r;
add_elements();
compile_set();
check_elements();
return perm;
}
};
vector<int> restore_permutation(int n, int w, int r) {
return subtask_full::restore_permutation(n, w, r);
}
# | 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... |