제출 #745385

#제출 시각아이디문제언어결과실행 시간메모리
745385Patrick순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; using ll = long long; std::vector<int> construct_permutation(long long k) { ll v = 1; ll a = 0; while (v * 2 <= k) { v *= 2; a++; } k -= v; vector<int> inc(a); while (k > 0) { ll s = 0; while ((1LL << (s + 1)) <= k) { s++; } inc[s] = a++; k -= (1LL << s); } vector<int> ans; for (int i = 0; i < inc.size(); i++) { if (inc[i] != 0) ans.push_back(inc[i]); ans.push_back(i); } return ans; }

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

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