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 <vector>
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MOD = (int)1e9 + 7;
int N;
void push(int s, int e){
if(s == e) return;
string in;
for(int i = 0; i < N; ++i){
if(i < s || i > e) in += '1';
else in += '0';
}
for(int i = s; i <= (s + e) / 2; ++i){
in[i] = '1';
add_element(in);
in[i] = '0';
}
push(s, (s + e) / 2), push((s + e) / 2 + 1, e);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N = n;
push(0, N - 1);
compile_set();
vector<vector<int>> now, nxt;
vector<int> all;
for(int i = 0; i < n; ++i){
all.push_back(i);
}
now.push_back(all);
for(int j = n; j > 1; j >>= 1){
for(int i = 0; i < (int)now.size(); ++i){
vector<int> l, r;
string in;
for(int x = 0; x < n; ++x){
in += '1';
}
for(auto&x:now[i]){
in[x] = '0';
}
for(auto&x:now[i]){
in[x] = '1';
if(check_element(in)){
l.push_back(x);
}
else{
r.push_back(x);
}
in[x] = '0';
}
nxt.push_back(l), nxt.push_back(r);
}
now = nxt;
nxt.clear();
}
vector<int> ans(n);
for(int i = 0; i < n; ++i){
ans[now[i].front()] = i;
}
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... |