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>
#define task "A"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 5;
int a[MAXN];
int n;
void DNC(int l, int r)
{
if (l == r)
{
return;
}
int mid = (l + r) / 2;
string s(n, '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';
}
DNC(l, mid);
DNC(mid + 1, r);
}
vector<int> phan[4 * MAXN], res;
void DNCAns(int id, int l, int r)
{
if (l == r)
{
res[phan[id].back()] = l;
return;
}
string s(n, '1');
for (int i : phan[id])
{
s[i] = '0';
}
for (int i : phan[id])
{
s[i] = '1';
if (check_element(s))
{
phan[2 * id].pb(i);
} else
{
phan[2 * id + 1].pb(i);
}
s[i] = '0';
}
int mid = (l + r) / 2;
DNCAns(2 * id, l, mid);
DNCAns(2 * id + 1, mid + 1, r);
}
vector<int> restore_permutation(int N, int w, int r)
{
res.resize(N);
n = N;
DNC(0, n - 1);
compile_set();
for (int i = 0; i < n; i++)
phan[1].pb(i);
DNCAns(1, 0, n - 1);
return res;
}
# | 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... |