제출 #702141

#제출 시각아이디문제언어결과실행 시간메모리
702141ld_minh4354순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" using namespace std; vector<int> construct_permutation(long long k) { long long a[5005],i,j,cur_val,pos,cur_k,n; cur_k=k; n=1;a[1]=0;cur_val=2; while (cur_val*2<=k) { n++;a[n]=n-1; cur_val*=2; } cur_k -= cur_val; while (cur_k > 0) { cur_val=1;pos=1; while (cur_val*2 <= cur_k) { pos++;cur_val*=2; } for (i=n+1;i>pos;i--) a[i]=a[i-1]; n++;a[pos]=n-1; cur_k -= cur_val; } vector<int> ans; for (i=1;i<n+1;i++) ans.push_back(a[i]); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:6:22: warning: unused variable 'j' [-Wunused-variable]
    6 |  long long a[5005],i,j,cur_val,pos,cur_k,n;
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...