Submission #957469

#TimeUsernameProblemLanguageResultExecution timeMemory
957469emad234Permutation (APIO22_perm)C++17
91.33 / 100
2 ms436 KiB
#include "perm.h" #include <bits/stdc++.h> #define ll long long #define F first #define S second #define pii pair<int, int> const int mod = 1e9 + 7; const int mxN = 1e4 + 100; using namespace std; std::vector<int> construct_permutation(long long k) { vector<int>ans; bool vis[64] = {}; int n = -1; for(int i = 60;i >= 0;i--){ if((k >> i) % 2){ if(n == -1) n = i; else vis[i] = 1; } } vector<int>v; int id = 0; for(int i = 0;i < n;i++){ if(vis[i]){ v.push_back(id); id++; } ans.push_back(id); id++; } while(v.size()){ ans.push_back(v.back()); v.pop_back(); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...