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>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "messy.h"
int N;
void build(int l,int r){
if(l == r){
return;
}
string x = "";
int mid = (l+r)/2;
f(i,0,N){
if(i < l || i > r){
x += "1";
}
else{
x += "0";
}
}
f(i,mid+1,r+1){
x[i] = '1';
add_element(x);
x[i] = '0';
}
build(l,mid);
build(mid+1,r);
}
vector<int>ans;
void solve(int l,int r,vector<int> arr){
if(l == r){
assert(arr.size() == 1);
ans[l] = arr[0];
return;
}
int mid = (l+r)/2;
vector<int>exo[2];
string x = "";
f(i,0,N){
x += "1";
}
for(auto y:arr){
x[y] = '0';
}
for(auto y:arr){
x[y] = '1';
exo[check_element(x)].pb(y);
x[y] = '0';
}
solve(l,mid,exo[0]);
solve(r,mid+1,exo[1]);
}
vector<int> restore_permutation(int n, int w, int r) {
N = n;
ans.assign(N,0);
build(0,n-1);
compile_set();
vector<int>arr;
f(i,0,n){
arr.pb(i);
}
solve(0,n-1,arr);
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... |