Submission #733646

#TimeUsernameProblemLanguageResultExecution timeMemory
733646Erkinoff_MohammedPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include "bits/stdc++.h" using namespace std; #define INF 2000000000 #define INFLL 3000000000000000000LL #define ll long long vector<int> construct_permutation(long long k){ vector<int>l; while(k>0){ long long n=1; int cnt=0; while(n*2<=k){ n<<=1; cnt++; } l.push_back(cnt); k-=n; } vector<int>vec(l[0]+l.size()-1); for(int i=0;i<l[0]+l.size()-1;i++){ vec[i]=i; } vector<int>en; for(int i=l.size()-1;i>0;i--){ en.push_back(vec[l[i]]); vec.erase(find(vec.begin(), vec.end(), vec[l[i]])); } for(int i=en.size()-1;i>-1;i--){ vec.push_back(en[i]); } return vec; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0;i<l[0]+l.size()-1;i++){
      |                 ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...