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"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int oo = 1000 * 1000 * 1000 + 7;
int N; vector<int> res;
void build(int l, int r) {
if(l == r) return;
int md = (l + r) / 2;
string S(N, '1');
for(int i = l; i <= r; i++) S[i] = '0';
for(int i = l; i <= md; i++) {
S[i] = '1';
add_element(S);
S[i] = '0';
}
build(l, (l + r) / 2);
build((l + r) / 2 + 1, r);
}
void solve(int l, int r, vector<int> A) {
if(l == r) {
res[A.back()] = l;
return;
}
string S(N, '1');
for(auto u : A) S[u] = '0';
vector<int> lo, hi;
for(auto u : A) {
S[u] = '1';
if(check_element(S)) lo.push_back(u);
else hi.push_back(u);
S[u] = '0';
}
solve(l, (l + r) / 2, lo);
solve((l + r) / 2 + 1, r, hi);
}
vector<int> restore_permutation(int n, int W, int R) {
N = n; res.assign(N, -1); build(0, N - 1);
compile_set(); vector<int> A(N);
for(int l = 0; l < N; l++) A[l] = l;
solve(0, N - 1, A);
return res;
}
# | 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... |