Submission #984884

# Submission time Handle Problem Language Result Execution time Memory
984884 2024-05-17T07:49:05 Z Kinoko_Sokora Permutation (APIO22_perm) C++17
0 / 100
0 ms 348 KB
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include<iomanip>
#include<queue>
#include<set>
#include<functional>
#include<tuple>
#include<bitset>
#include<cassert>
#include<cstdint>
#include<complex>
#include<random>
#include<fstream>
#include <unordered_map>  
#include <unordered_set>  
using namespace std;
bool printb(bool f) {
	if (f)printf("Yes\n");
	else printf("No\n");
	return f;
}
template<class T>
void prt(T t = "", string sep = "\n") { cout << t << sep; return; }
template<class T>
void printl(vector<T> a, string sep = " ") {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i != a.size() - 1)cout << sep;
	}
	cout << "\n";
	return;
}

bool prt_isfixed = false;
template<class T>
void prt_fix(T t, string sep = "\n") {
	if (!prt_isfixed) {
		cout << fixed << setprecision(15);
		prt_isfixed = true;
	}
	prt(t, sep);
}
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#pragma GCC target "prefer-vector-width=512"
#pragma GCC optimize "Ofast"
#pragma GCC optimize("unroll-loops")

using uint = unsigned int;
using llong = long long;
using ullong = unsigned long long;
using pii = pair<int, int>;
using pll = pair<llong, llong>;
using pli = pair<llong, int>;
using pil = pair<int, llong>;
template<typename T> using vec2 = vector<vector<T>>;
template<typename T> inline bool chmin(T& a, T b) { return (a > b) ? (a = b, true) : false; }
template<typename T> inline bool chmax(T& a, T b) { return (a < b) ? (a = b, true) : false; }
bool bitIn(llong a, int b) { return ((a >> b) & 1); }
int bitCnt(llong a) {
	int re = 0;
	while (a > 0) {
		if (a & 1)re++;
		a >>= 1;
	}
	return re;
}
llong powL(llong n, llong i) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) re *= n;
		n *= n;
		i >>= 1;
	}
	return re;
}
llong powL_M(llong n, llong i, llong mod) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) {
			re *= n;
			re %= mod;
		}
		n *= n;
		n %= mod;
		i >>= 1;
	}
	return re;
}


llong cei(llong a, llong b) {
	if (a % b == 0)return a / b;
	else if (a < 0) {
		return a / b;
	}
	else {
		return a / b + 1;
	}
}

llong flo(llong a, llong b) {
	if (a % b == 0)return a / b;
	else if (a < 0) {
		return a / b - 1;
	}
	else {
		return a / b;
	}
}
int  dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int  dx2[8] = { -1,-1,1,1,-1,-1,1,1 }, dy2[8] = { 1,-1,-1,1,1,-1,-1,1 };
int dx8[8] = { 0,1,1,1,0,-1,-1,-1 }, dy8[8] = { -1,-1,0,1,1,1,0,-1 };


#include "perm.h"

std::vector<int> construct_permutation(long long k){
	k--;//空配列のぶん抜く
	vector<int> num(60);
	//2^i-1をいくつ使うか
	for (int i = 59; i >= 1; i--) {
		llong nu = (llong(1) << i) - 1;
		num[i] = k / nu;
		k %= nu;
	}
	vector<int> re;
	int cnt = 0;
	rep(i, 60) {
		rep(l,num[i]){
			rep(j, i) {
				re.push_back(cnt + i - j - 1);
			}
		}
		cnt += i;
	}
	reverse(all(re));
	return re;

}
/*
int main() {
	llong k;
	cin >> k;
	printl(construct_permutation(k));
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -