This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// ~ Be Name Khoda ~ //
#include "messy.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e5 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
string t = "";
int n;
vector <int> ans;
void build(int l, int r){
if(r - l == 1)
return;
int mid = (l + r) >> 1;
string s = t;
for(int x = 0; x < l; x++)
s[x] = '1';
for(int x = r; x < n; x++)
s[x] = '1';
for(int i = l; i < mid; i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
build(l, mid);
build(mid, r);
}
void solve(int l, int r, vector <int> av){
if(r - l == 1){
ans[av[0]] = l;
return;
}
int mid = (l + r) >> 1;
string s = t;
for(int x = 0; x < n; x++)
s[x] = '1';
for(auto u : av)
s[u] = '0';
vector <int> av1, av2;
for(auto x : av){
s[x] = '1';
if(check_element(s))
av1.pb(x);
else
av2.pb(x);
s[x] = '0';
}
solve(l, mid, av1);
solve(mid, r, av2);
}
std::vector<int> restore_permutation(int N, int w, int r) {
n = N;
for(int i = 0; i < n; i++)
t.pb('0');
build(0, n);
compile_set();
vector <int> av;
for(int i = 0; i < n; i++){
av.pb(i);
ans.pb(i);
}
solve(0, n, av);
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... |