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;
void add_elements(int l, int r)
{
if (l == r)
return;
int mid = (l + r) / 2;
string s;
for (int i = 0; i < n; i++)
s += "1";
for (int i = l; i <= r; i++)
s[i] = '0';
for (int i = l; i <= mid; i++)
{
s[i] = '1';
add_element(s);
s[i] = '0';
}
add_elements(l, mid);
add_elements(mid + 1, r);
}
int p[128];
void get_elements(int l, int r, vector <int> el)
{
if (l == r)
{
p[el[0]] = l;
return;
}
vector <int> left;
string s;
for (int i = 0; i < n; i++)
s += "1";
for (auto i: el)
s[i] = '0';
for (auto i: el)
{
s[i] = '1';
if (check_element(s))
left.push_back(i);
s[i] = '0';
}
vector <int> right;
for (auto i: el)
{
bool is = false;
for (auto j: left)
if (i == j)
{
is = true;
break;
}
if (!is)
right.push_back(i);
}
int mid = (l + r) / 2;
get_elements(l, mid, left);
get_elements(mid + 1, r, right);
}
vector <int> restore_permutation(int _n, int w, int r)
{
n = _n;
add_elements(0, n-1);
compile_set();
vector <int> v;
for (int i = 0; i < n; i++)
v.push_back(i);
get_elements(0, n-1, v);
vector <int> ans;
for (int i = 0; i < n; i++)
ans.push_back(p[i]);
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... |