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>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i,j,N,a[1010];
string s;
void buat(ll aa,ll bb)
{
if(aa==bb)return ;
ll besar=(bb-aa+1),ii;
string z;
for(ii=0;ii<N;ii++)z+="1";
for(ii=aa;ii<=bb;ii++)z[ii]='0';
for(ii=aa;ii<aa+(besar/2);ii++)
{
z[ii]='1';
add_element(z);
//cout<<z<<"\n";
z[ii]='0';
}
buat(aa,aa+besar/2-1);
buat(aa+besar/2,bb);
}
void cari(ll aa,ll bb,string cc)
{
//cout<<aa<<" "<<bb<<" "<<cc<<"\n";
ll ii;
if(aa==bb)
{
for(ii=0;ii<N;ii++)
if(cc[ii]=='0')
{
a[ii]=aa;
return ;
}
return ;
}
string ki=cc;
string ka=cc;
string tan=cc;
ll besar=(bb-aa+1);
for(ii=0;ii<N;ii++)
if(cc[ii]=='0')
{
tan[ii]='1';
if(check_element(tan))ka[ii]='1';
else ki[ii]='1';
tan[ii]='0';
}
cari(aa,aa+besar/2-1,ki);
cari(aa+besar/2,bb,ka);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N=n;
buat(0,n-1);
compile_set();
for(i=0;i<n;i++)s+="0";
cari(0,n-1,s);
vector<int> has(n);
for(i=0;i<n;i++)
has[i]=a[i];
return has;
}
# | 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... |