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"
// #include "grader.cpp"
using namespace std;
string s = "";
int na;
vector<int> ans;
void fill(int l, int r, char c) {
for(int i = l;i<=r;i++) {
s[i] = c;
}
}
void add(int l, int r) {
fill(0, na-1, '0');
fill(0, l-1, '1');
fill(r+1, na-1, '1');
int mid = (l+r)/2;
for(int i = l;i<=mid;i++) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(l, mid);
add(mid+1, r);
}
void solve(vector<int> v, int l, int r) {
if(l == r) {
ans[l] = v[0];
}
fill(0, na-1, '0');
fill(0, l-1, '1');
fill(r+1, na-1, '1');
int mid = (l+r)>>1ll;
vector<int> left, right;
for(int i:v) {
s[i] = '1';
if(check_element(s)) {
left.push_back(i);
}
else right.push_back(i);
s[i] = '0';
}
solve(left, l, mid);
solve(right, mid+1, r);
}
std::vector<int> restore_permutation(int N, int w, int r) {
na = N;
for(int i = 0;i<na;i++)s+="0";
vector<int> v(na);
ans.resize(na);
add(0, na-1);
compile_set();
solve(v, 0, na-1);
// for(int i = 0;i<na;i++)cout << i << ": " << ans[i] << " ";
// 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... |