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"
//#include "Lgrader.cpp"
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
int n;
void prec(int l, int r)
{
if(l == r)
return;
int mid = (l + r) >> 1;
for(int i = l; i <= mid; i++)
{
string s(::n, '0');
for(int j = l; j <= r; j++)
s[j] = '1';
s[i] = '0';
add_element(s);
}
prec(l, mid);
prec(mid + 1, r);
}
void get(int l, int r, vector<int> cands, vector<int> &ret)
{
if(l == r)
{
ret[cands.back()] = l;
return;
}
vector<int> L, R;
int mid = (l + r) >> 1;
for(int i: cands)
{
string s(::n, '0');
for(int j: cands)
s[j] = '1';
s[i] = '0';
if(check_element(s))
L.push_back(i);
else
R.push_back(i);
}
get(l, mid, L, ret);
get(mid + 1, r, R, ret);
}
vector<int> restore_permutation(int n, int w, int r)
{
::n = n;
w--; r--;
string tmp(n, '0');
prec(0, n - 1);
compile_set();
vector<int> ret(n, 0);
vector<int> cands(n, 0);
for(int i = 0; i < n; i++)
cands[i] = i;
get(0, n - 1, cands, ret);
return ret;
}
# | 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... |