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 n;
vector<int> ans;
void create(int l, int r)
{
if (l + 1 == r) return;
string s(n, '1');
for (int i = l; i < r; i++) s[i] = '0';
for (int i = l; i < ((l + r) >> 1); i++)
{
s[i] = '1';
add_element(s);
s[i] = '0';
}
create(l, (l + r) >> 1);
create((l + r) >> 1, r);
}
void getans(int l, int r, vector<int> v)
{
if (l + 1 == r)
{
ans[v[0]] = l;
return;
}
string s(n, '1');
for (int i : v) s[i] = '0';
vector<int> V[2];
for (int i : v)
{
s[i] = '1';
int x = check_element(s);
s[i] = '0';
if (x) V[0].push_back(i);
else V[1].push_back(i);
}
getans(l, (l + r) >> 1, V[0]);
getans((l + r) >> 1, r, V[1]);
}
vector<int> restore_permutation(int N, int w, int r)
{
n = N;
create(0, n);
compile_set();
vector<int> v(n, 0);
iota(v.begin(), v.end(), 0);
ans.assign(n, 0);
getans(0, n, v);
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... |