Submission #911301

#TimeUsernameProblemLanguageResultExecution timeMemory
911301hjroh0315Permutation (APIO22_perm)C++17
91.33 / 100
2 ms356 KiB
#include"perm.h" #include<bits/stdc++.h> using namespace std; std::vector<int>construct_permutation(long long k) { vector<int>ans; auto f=k;int last=-1; for(int i=0;i<62;i++) { if(f>0) { if(f&1)f--; if(f>0)ans.push_back(i); last=i; f>>=1; } } last--; while(last>=0) { if(k>>last&1) { for(int i=0;i<size(ans);i++) { if(ans[i]>=last)ans[i]++; } ans.push_back(last); } last--; } return ans; }

Compilation message (stderr)

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