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;
string s;
void fill_set(int le, int ri)
{
if(ri-le==1)
{
s[le]='1';
///cout<<s<<endl;
add_element(s);
s[le]='0';
return;
}
else
{
int mid=(le+ri)/2;
for(int i=le; i<=mid; i++)
{
s[i]='1';
///cout<<s<<endl;
add_element(s);
s[i]='0';
}
for(int i=le; i<=mid; i++) s[i]='1';
fill_set(mid+1, ri);
for(int i=le; i<=mid; i++) s[i]='0';
s[ri]='1';
fill_set(le, mid);
s[ri]='0';
}
}
vector<int> res, res2;
void solve_res(int le, int ri)
{
if(ri-le==1)
{
s[res[le]]='1';
bool ans=check_element(s);
s[res[le]]='0';
if(!ans) swap(res[le], res[ri]);
return;
}
int id=le;
for(int i=le; i<=ri; i++)
{
s[res[i]]='1';
bool ans=check_element(s);
s[res[i]]='0';
if(ans) {swap(res[id], res[i]); id++;}
}
int mid=(le+ri)/2;
for(int i=le; i<=mid; i++) s[res[i]]='1';
solve_res(mid+1, ri);
for(int i=le; i<=mid; i++) s[res[i]]='0';
s[res[ri]]='1';
solve_res(le, mid);
s[res[ri]]='0';
}
std::vector<int> restore_permutation(int n, int w, int r)
{
N=n;
s.resize(n, '0');
fill_set(0, N-1);
compile_set();
///cout<<endl;
s.resize(n, '0');
for(int i=0; i<N; i++) res.push_back(i);
solve_res(0, N-1);
res2.resize(N);
for(int i=0; i<N; i++) res2[res[i]]=i;
return res2;
}
# | 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... |