Submission #982983

#TimeUsernameProblemLanguageResultExecution timeMemory
982983Faisal_SaqibPermutation (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define vll vector<ll> vector<int> construct_permutation(ll k) { vector<int> ans; ll n_req=0; ll hb=-1; for(int j=59;j>=0;j--) { ll pw=(1ll<<j); if(k&pw) { if(hb==-1) { n_req+=j; hb=j; } else n_req++; } } ll last=n_req-1; int first=0; // cout<<last<<endl; for(int l=0;l<60 and l<hb;l++) { if(k&(1ll<<l)) { ans.push_back(first); first++; } if(first<=last) { ans.push_back(last); last--; } } reverse(begin(ans),end(ans)); return ans; } // int main() // { // int n; // cin>>n; // auto tp= construct_permutation(n); // for(auto k:tp) // { // cout<<k<<' '; // } // cout<<endl; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...