Submission #1035248

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