제출 #707473

#제출 시각아이디문제언어결과실행 시간메모리
707473josanneo22순열 (APIO22_perm)C++17
91.33 / 100
2 ms468 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; std::vector<int> construct_permutation(long long k) { int pow = 0; while ((1ll << pow) <= k) pow++; pow--; int cnt = pow; vector<int> arr(pow, -1); for (int i = pow - 1; i >= 0; --i) { if (k & (1ll << i)) { arr[i] = pow++; } } vector<int> ret; for (int i = 0; i < arr.size(); ++i) { if (arr[i] != -1) ret.push_back(arr[i]); ret.push_back(i); } return ret; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < arr.size(); ++i) {
      |                  ~~^~~~~~~~~~~~
perm.cpp:9:6: warning: unused variable 'cnt' [-Wunused-variable]
    9 |  int cnt = pow;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...