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