Submission #910692

#TimeUsernameProblemLanguageResultExecution timeMemory
910692efedmrlrPermutation (APIO22_perm)C++17
64.62 / 100
11 ms1880 KiB
#include "perm.h"
// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;


#define lli long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


const double EPS = 0.00001;
const int INF = 1e9+500;
const int N = 3e5+5;
const int ALPH = 26;
const int LGN = 60;
constexpr int MOD = 1e9+7;
int n,m,q;

std::vector<int> construct_permutation(long long k)
{
	int nxt = 0;
	k--;
	vector<vector<int> > gr(LGN*2);
	
	for(int i = 1; i<LGN*2; i++) {

		if(i < LGN) {
			if(k & (1ll<<i)) {
				for(int j = 0; j < max(1, i); j++) {
					gr[i].pb(nxt); nxt++;
				}
			}
		}
		else {
			if(k & (1ll<<(1ll * (i - LGN)))) {
				gr[i].pb(nxt); nxt++;
			}
		}
	}
	vector<int> ret;
	for(int i = 2*LGN - 1; i>=0; i--) {
		for(auto c : gr[i]) {
			// cout<<c<<" ";
			ret.pb(c);
		}
	}
	// cout<<endl;
	return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...