제출 #954489

#제출 시각아이디문제언어결과실행 시간메모리
954489horiseun순열 (APIO22_perm)C++17
64.63 / 100
12 ms1628 KiB
#include <iostream> #include <vector> #include <algorithm> #include "perm.h" using namespace std; #define ll long long vector<int> construct_permutation(ll k) { vector<ll> pwrs; pwrs.push_back((ll) 1); for (int i = 0; i < 59; i++) { pwrs.push_back(pwrs.back() * 2); } vector<int> szs; for (int i = pwrs.size() - 1; i >= 0; i--) { if (k >= pwrs[i]) { szs.push_back(i); k -= pwrs[i]; } } /* for (int i = 0; i < szs.size(); i++) { cout << szs[i] << "\n"; } */ vector<int> ret; int curr = 0; for (int i = 0; i < szs.size(); i++) { for (int j = curr + szs[i] - 1; j >= curr; j--) { ret.push_back(j); } curr += szs[i]; } for (int i = 0; i < szs.size() - 1; i++) { ret.push_back(curr + i); } reverse(ret.begin(), ret.end()); /* for (int i = 0; i < ret.size(); i++) { cout << ret[i] << " "; } cout << "\n"; */ return ret; }

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

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