제출 #1200169

#제출 시각아이디문제언어결과실행 시간메모리
1200169browntoadPermutation (APIO22_perm)C++20
71.22 / 100
7 ms1096 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())

namespace{
    const ll maxn  = 1e5+5;
    const ll mod = 1e9+7;
    const ll inf = (1ll<<60);
}

pair<int, vector<int>> make_bin(long long k, int cur){ // other method: make with binary
	k--;
	vector<int> ret;
	if (k == 0) return {cur, ret};
	for (int i = 61; i >= 1; i--){
		ll tmp = (1ll<<i)-1;
		while (k >= tmp){
			k -= tmp;
			vector<int> poo;
			REP(j, i) poo.pb(cur++);
			RREP(j, SZ(poo)) ret.pb(poo[j]);
		}
	}
	reverse(ALL(ret));
	return {cur, ret};
}
pair<int, vector<int>> make_bao(long long k, int cur){
	k--;
	vector<int> ret;
	if (k == 0) return {cur, ret};
	REP(i, k) ret.pb(cur++);
	reverse(ALL(ret));
	return {cur, ret};
}
std::vector<int> construct_permutation(long long k){
	k--; // imma make it a bunch of sums

	vector<int> ret = make_bin(k+1, 0).s; // initially all reversed
	return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...