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> //Andrei Alexandru a.k.a Sho10
#include "messy.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[130];
void build(ll l,ll r){
if(l==r){
return;
}
string s="";
for(ll i=0;i<n;i++)
{
s.pb('0');
}
for(ll i=l;i<=r;i++)
{
s[i]='1';
}
ll mid=(l+r)/2;
for(ll i=mid+1;i<=r;i++)
{
s[i]='0';
add_element(s);
s[i]='1';
}
build(l,mid);
build(mid+1,r);
}
void calc(ll l,ll r,vector<ll>vec){
if(l==r){
a[vec[0]]=l;
return;
}
ll mid=(l+r)/2;
string s="";
for(ll i=0;i<n;i++)
{
s.pb('0');
}
for(auto &it : vec){
s[it]='1';
}
vector<ll>x,y;
for(auto &i : vec){
s[i]='0';
if(check_element(s)){
y.pb(i);
}else x.pb(i);
s[i]='1';
}
calc(l,mid,x);
calc(mid+1,r,y);
}
vector<int>restore_permutation(int N,int w,int r){
n=N;
build(0,n-1);
compile_set();
vector<ll>v;
for(ll i=0;i<n;i++)
{
v.pb(i);
}
calc(0,n-1,v);
vector<int>ans;
for(ll i=0;i<n;i++)
{
ans.pb(a[i]);
}
return ans;
}
/*
int32_t main(){
CODE_START;
*/
# | 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... |