이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
int ans[200];
int n;
void build(int l,int r)
{
if(l==r||r<l) return;
string s=string(n,'1');
for(int i=l;i<=r;i++) s[i]='0';
int mid=(l+r)/2;
for(int i=l;i<=mid;i++)
{
s[i]='1'; add_element(s);
s[i]='0';
}
build(l,mid); build(mid+1,r);
}
void solve(int l,int r,vector<int> ind)
{
/*cout << l << " " << r << " : ";
for(int i:ind) cout << i << " ";
cout << endl;*/
if(l==r)
{
ans[ind[0]]=l;
return;
}
vector<int> ll,rr;
string s=string(n,'1');
for(int i:ind) s[i]='0';
for(int i:ind)
{
s[i]='1';
//cout << s << endl;
if(check_element(s))
ll.push_back(i);
else
rr.push_back(i);
s[i]='0';
}
int mid=(l+r)/2;
solve(l,mid,ll);
solve(mid+1,r,rr);
}
std::vector<int> restore_permutation(int nn, int w, int r) {
/*add_element("0");
compile_set();
check_element("0");
return std::vector<int>();*/
n=nn;
//cout << "OK" << endl;
build(0,n-1);
//cout << "OK" << endl;
compile_set();
//cout << "OK" << endl;
vector<int> v;
for(int i=0;i<n;i++) v.push_back(i);
solve(0,n-1,v);
vector<int> ret;
for(int i=0;i<n;i++) ret.push_back(ans[i]);
//for(int i:ret) cout << i << " "; cout << endl;
return ret;
}
# | 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... |