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;
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 = "00000000";
vector <pair<pair<int, pair<int, int>>, string>> av;
void build(int l, int r){
if(r - l == 1)
return;
int mid = (l + r) >> 1;
string s = t;
for(int i = l; i < mid; i++)
s[i] = '1';
av.pb({{r - l, {l, r}}, s});
add_element(s);
build(l, mid);
build(mid, r);
}
std::vector<int> restore_permutation(int n, int w, int r) {
build(0, n);
compile_set();
sort(all(av));
vector <int> ans;
for(int i = 0; i < n; i++)
ans.pb(i);
while(av.size()){
string s = av.back().se;
int l = av.back().fi.se.fi, r = av.back().fi.se.se;
int mid = (l + r) >> 1;
av.pop_back();
if(check_element(s))
continue;
for(int i = l; i < mid; i++) for(int j = mid; j < r; j++){
s[i] = '0';
s[j] = '1';
if(check_element(s)){
swap(ans[i], ans[j]);
return ans;
}
s[i] = '1';
s[j] = '0';
}
}
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... |