이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
vector<int> res;
int N;
void build(int low,int high)
{
if(low==high)
return ;
string X="";
int mid=(low+high)/2;
for(int A=0;A<N;A++)
{
if(A<low or A>high)
X+="1";
else
X+="0";
}
for(int A=low;A<=mid;A++)
{
X[A]='1';
add_element(X);
X[A]='0';
}
build(low,mid);
build(mid+1,high);
return ;
}
void solve(int low,int high,vector<int> lol)
{
vector<int> present,absent,now;
for(int B=0;B<N;B++)
{
if(lol[B])
present.pb(B);
else
absent.pb(B);
}
if(low==high)
{
res[present[0]]=low;
return ;
}
string X="";
for(int A=0;A<N;A++)
X+="0";
for(auto A:absent)
X[A]='1';
for(int A=0;A<N;A++)
{
if(X[A]=='1')
continue;
X[A]='1';
if(check_element(X))
now.pb(A);
X[A]='0';
}
int mid=(low+high)/2;
vector<int> f(N,0),s(N,1);
for(auto A:now)
f[A]=1;
for(auto A:now)
s[A]=0;
for(auto A:absent)
s[A]=0;
solve(low,mid,f);
solve(mid+1,high,s);
return ;
}
vector<int> restore_permutation(int n,int w,int r)
{
/*add_element("0");
compile_set();
check_element("0");*/
vector<int> f(n,1);
N=n;
res.resize(n);
build(0,n-1);
compile_set();
solve(0,n-1,f);
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... |