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>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7;
vi restore_permutation(int n, int w, int r) {
{
function<void(int, int, string)> dfs = [&] (int l, int r, string s) {
if(r - l == 1) return;
int m = (l + r) / 2;
for(int i = l; i < m; i++) {
string t = s;
t[i] = '1';
add_element(t);
}
{
string t = s;
for(int i = m; i < r; i++)
t[i] = '1';
dfs(l, m, t);
}
{
string t = s;
for(int i = l; i < m; i++)
t[i] = '1';
dfs(m, r, t);
}
};
dfs(0, n, string(n, '0'));
}
compile_set();
vi ans(n);
{
function<void(int, int, string, vi)> dfs = [&] (int l, int r, string s, vi x) {
assert(SZ(x) == r - l);
if(r - l == 1) {
ans[x[0]] = l;
return;
}
int m = (r + l) / 2;
vi left, right;
for(int i:x) {
string t = s;
t[i] = '1';
if(check_element(t)) {
left.PB(i);
} else {
right.PB(i);
}
}
cout << SZ(left) << " " << SZ(right) << endl;
{
string t = s;
for(int i:right)
t[i] = '1';
dfs(l, m, t, left);
}
{
string t = s;
for(int i:left)
t[i] = '1';
dfs(m, r, t, right);
}
};
vi tt;
for(int i = 0; i < n; i++) tt.PB(i);
dfs(0, n, string(n, '0'), tt);
}
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... |