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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int N;
void add(int l,int r){
if(r - l==1)return;
int m = (l + r) / 2;
string s(N,'0');
for(int i = l; i < r; i++) s[i] = '1';
for(int i = l;i < m ;i++){
s[i] = '0';
add_element(s);
s[i] = '1';
}
add(l, m); add(m, r);
}
vector<int>u;
void solve(vector<int> v){
if(v.size() == 1) return;
string s(N,'0');
for(int i : v) s[i] = '1';
int add = v.size()/2;
vector<int> a, b;
for(int i : v){
s[i] = '0';
if(check_element(s)) a.push_back(i);
else b.push_back(i), u[i] += add;
s[i] = '1';
}
solve(a); solve(b);
}
vector<int> restore_permutation(int n, int w, int r) {
N = n;
add(0,N);
compile_set();
vector<int>v(n);
for(int i = 0; i < n; i++) v[i] = i;
u = vector<int>(n);
solve(v);
return u;
}
# | 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... |