Submission #619529

#TimeUsernameProblemLanguageResultExecution timeMemory
619529LoboPermutation (APIO22_perm)C++17
96.33 / 100
547 ms460 KiB
#include "perm.h" #include<iostream> #include<vector> #include<deque> #include<math.h> using namespace std; #define int long long vector<int32_t> construct_permutation(int k) { int k1 = k; int k2 = 1; vector<int> ks; for(int i = 2; i <= min((int) 5e5,k); i++) { while(k%i == 0) { ks.push_back(i); k/=i; } } ks.push_back(k); vector<int32_t> vc; for(auto k1 : ks) { deque<int> ans; // int lg = 0; // for(int i = 0; i <= 60; i++) { // if(k1 >= (1LL<<i)) lg = i; // } int lg = log2(k1); for(int i = lg-1; i >= 0; i--) { ans.push_back((int) ans.size()+vc.size()); if(k1&(1LL<<i)) ans.push_front((int) ans.size()+vc.size()); } // cout << " " << k1 << endl; for(auto x : ans) { // cout << " 1 " << x << endl; vc.push_back(x); } } return vc; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:11:6: warning: unused variable 'k1' [-Wunused-variable]
   11 |  int k1 = k;
      |      ^~
perm.cpp:12:6: warning: unused variable 'k2' [-Wunused-variable]
   12 |  int k2 = 1;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...