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>
using namespace std;
const int nx=128;
int N;
bool vs[nx], t[nx];
vector<int> ans;
string s;
void add(int l, int r)
{
int md=(l+r)/2;
for (int i=0; i<N; i++) s[i]='1';
for (int i=l; i<r; i++) s[i]='0';
for (int i=l; i<md; i++) s[i]='1', add_element(s), s[i]='0';
if (r-l>2) add(l, md), add(md, r);
}
void check(vector<int> c, int l, int r)
{
vector<int> g1, g2;
int md=(l+r)/2;
for (int i=0; i<N; i++) s[i]='1';
for (auto x:c) s[x]='0';
for (auto x:c)
{
s[x]='1';
if (check_element(s)) g1.push_back(x);
else g2.push_back(x);
s[x]='0';
}
if (c.size()>2) check(g1, l, md), check(g2, md, r);
else ans[g1[0]]=l, ans[g2[0]]=l+1;
}
vector<int> restore_permutation(int n, int w, int r) {
N=n;
ans.resize(N);
for (int i=0; i<n; i++) s+='0';
add(0, n);
compile_set();
vector<int> tmp;
for (int i=0; i<n; i++) tmp.push_back(i);
check(tmp, 0, n);
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... |