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