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;
vector<int> ans;
void add(int l, int r, int n){
if(l == r) return;
int m = (l + r) / 2;
string s(n, '1');
for(int i = l; i <= r; i++){
s[i] = '0';
}
for(int i = l; i <= m; i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(l, m, n);
add(m + 1, r, n);
}
void get(int l, int r, int n, const vector<int> &perm){
if(r == l){
ans[perm[0]] = l;
return;
}
int m = (l + r) / 2;
string s(n, '1');
vector<int> on, off;
for(int x : perm) s[x] = '0';//perm-ben vannak a lehetseges dolgok
for(int x : perm){
s[x] = '1';
(check_element(s) ? on : off).push_back(x);
s[x] = '0';
}
get(l, m, n, on);
get(m + 1, r, n, off);
}
std::vector<int> restore_permutation(int n, int w, int r) {
ans.resize(n);
add(0, n - 1, n);
compile_set();
vector<int> start(n);
iota(start.begin(), start.end(), 0);
get(0, n - 1, n, start);
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... |