제출 #985136

#제출 시각아이디문제언어결과실행 시간메모리
985136vjudge1순열 (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define pii pair<int,int>
#define ss second
#define ff first
#define debu(x) (cerr << #x  << " = "<< x << "\n")

std::vector<int> construct_permutation(long long k)
{
	//cout << "k is " << k << "\n";
	#define int long long
	vector<int32_t>ans;
	int ochako=0;
	int got = 0;
	for (int a = 63; a >= 0; a--)
	{
		if (((((int)1) << a) & (k)))
		{
			//cout << "ak " << a << " " << k << "\n";
			if (!ochako)
			{
				got = a - 1;
				ochako = a;
				for (int b = 0; b < a; b++)
				{
					ans.pb(b);
				}
			}
		}
	}
	//cout << ochako << "ochako\n";
	for (int a = ochako-1; a >= 0; a--)
	{
		//cout << "once " << a << "\n";
		if (((((int)1) << a) & (k)))
		{
			got++;
			ans.insert(ans.begin() + a, got);
		}
	}
	/*cout << "outputting the arr:\n";
	for (int x : ans)
	{
		cout << x << " ";
	}
	cout << "dante\n";*/
	#undef int
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...