Submission #919101

#TimeUsernameProblemLanguageResultExecution timeMemory
919101Mher777Permutation (APIO22_perm)C++17
64.62 / 100
12 ms1624 KiB
#include "perm.h"
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
using namespace std;

/* -------------------- Typedefs -------------------- */

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef float fl;
typedef long double ld;

/* -------------------- Usings -------------------- */

using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* -------------------- Defines -------------------- */

#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) (x).begin(), (x).end()

/* -------------------- Constants -------------------- */

const int MAX = int(2e9 + 5);
const ll MAXL = ll(1e18) + 5ll;
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);

std::vector<int> construct_permutation(long long k) {
	vi ans;
	--k;
	bitset<66> bit = k;
	int beg = 0;
	for (int i = 0; i <= 64; ++i) {
		if (!bit[i]) continue;
		if (i == 0) {
			ans.pub(0);
			++beg;
			continue;
		}
		for (int j = beg + i - 1; j >= beg; --j) {
			ans.pub(j);
		}
		ans.pub(beg + i);
		beg += i + 1;
	}
	reverse(all(ans));
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...