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;
vector<int>rez;
void build(int st,int dr)
{
if (st==dr)
return ;
string ans=string(n,'0');
int i;
for(i=st;i<=dr;i++)
ans[i]='1';
int mij=(st+dr)/2;
for(i=st;i<=mij;i++){
ans[i]='0';
add_element(ans);
ans[i]='1';
}
build(st,mij);
build(mij+1,dr);
}
void solve(int st,int dr,vector<int>&v)
{
if (st==dr){
rez[v[0]]=st;
return ;
}
vector<int>vst,vdr;
string aux=string(n,'0');
for(auto it:v)
aux[it]='1';
for(auto it:v){
aux[it]='0';
if (check_element(aux))
vst.push_back(it);
else
vdr.push_back(it);
aux[it]='1';
}
int mij=(st+dr)/2;
solve(st,mij,vst);
solve(mij+1,dr,vdr);
}
vector<int> restore_permutation(int n2,int w,int r)
{
n=n2;
vector<int>aux(n);
iota(aux.begin(),aux.end(),0);
rez.resize(n);
build(0,n-1);
compile_set();
solve(0,n-1,aux);
return rez;
}
# | 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... |