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<bits/stdc++.h>
using namespace std;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
#include "messy.h"
namespace BRUV{
ll n;
ll cnt_w,cnt_r;
vector <ll> p;
void add(ll l,ll r){
if (l == r)return;
string s;
s.resize(n,'0');
for (ll i = 0;i < l;i ++)s[i] = '1';
for (ll i = r+1;i < n;i ++)s[i] = '1';
ll mid = (l + r) >> 1;
for (ll i = l;i <= mid;i ++){
s[i] = '1';
add_element(s);
// assert(++cnt_w <= 128*3);
s[i] = '0';
}
add(l,mid);
add(mid+1,r);
}
void solve(ll l,ll r,vector <ll> all_pos){
if (l==r){p[all_pos[0]] = l;return;}
string s;
s.resize(n,'1');
for (auto x:all_pos)s[x] = '0';
vector <ll> L,R;
ll mid = (l + r) >> 1;
for (auto x:all_pos){
s[x]='1';
if (check_element(s))L.push_back(x);
else R.push_back(x);
// assert(++cnt_r <= 128*3);
s[x]='0';
}
solve(l,mid,L);
solve(mid+1,r,R);
}
}
std::vector<int> restore_permutation(int N, int w, int r) {
using namespace BRUV;
n=N;
p.resize(n,-1);
add(0,n-1);
compile_set();
vector <ll> sus(n);
iota(sus.begin(),sus.end(),0);
solve(0,n-1,sus);
return p;
}
# | 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... |