Submission #1035332

#TimeUsernameProblemLanguageResultExecution timeMemory
1035332amine_arouaPermutation (APIO22_perm)C++17
64.62 / 100
10 ms1624 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
std::vector<int> construct_permutation(long long k)
{
	k--;
	int n = 0;
    vector<int> bits;
	for(ll i = 0 ; i < 60 ; i++)
	{
		if((1ll<<i) & k)
		{
            bits.push_back(i);
			n+=i + 1;
		}
	}
    n--;
    vector<int> perm;
    for(auto i : bits)
    {
        for(int j = n - i + 1 ; j <= n ; j++)
        {
            perm.push_back(j);
        }
        n-=i;
    }
    while(n >= 0)
    {
        perm.push_back(n);
        n--;
    }
    return perm;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...