제출 #725198

#제출 시각아이디문제언어결과실행 시간메모리
725198Batorgil952순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include<bits/stdc++.h> #include "perm.h" using namespace std; std::vector<int> construct_permutation(long long k) { vector< int > v; int a[62]={0}, b[62]={0}; long long m=k, f=-1, r; for(int i=0; i<=60; i++){ if(m%2==1){ a[i]=1; } m/=2; } for(int i=60; i>=0; i--){ if(a[i]>0){ if(f==-1){ f=i; r=f; } else{ b[i]=f; f++; } } } for(int i=0; i<=60; i++){ if(b[i]>0) v.push_back(b[i]); if(i<r) v.push_back(i); } return v; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:31:3: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |   if(i<r) v.push_back(i);
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...