제출 #976100

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
9761002024-05-06 07:46:03rythm_of_knight순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include "perm.h"
#define int long long
using namespace std;
vector<int> construct_permutation(int k) {
int temp = --k;
vector <int> v;
while (temp) {
v.push_back(temp & 1);
temp >>= 1;
}
int sz = v.size();
for (int i = 0; i < sz; i++) {
while (i > 0 && v[i - 1] == 0 && v[i] > 0) {
v[i - 1] += 2;
v[i]--;
i--;
}
}
int cnt = -1;
vector <int> ans;
for (int i = 0; i < sz; i++) {
vector <int> t;
while (v[i]--) {
t.push_back(++cnt);
}
reverse(t.begin(), t.end());
for (int &u : t) {
ans.push_back(u);
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

perm.cpp:4:13: error: ambiguating new declaration of 'std::vector<long long int> construct_permutation(long long int)'
    4 | vector<int> construct_permutation(int k) {
      |             ^~~~~~~~~~~~~~~~~~~~~
In file included from perm.cpp:1:
perm.h:3:18: note: old declaration 'std::vector<int> construct_permutation(long long int)'
    3 | std::vector<int> construct_permutation(long long k);
      |                  ^~~~~~~~~~~~~~~~~~~~~
perm.cpp: In function 'std::vector<long long int> construct_permutation(long long int)':
perm.cpp:26:9: error: 'reverse' was not declared in this scope
   26 |         reverse(t.begin(), t.end());
      |         ^~~~~~~
perm.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
perm.cpp:35:12: error: could not convert 'ret' from 'long long int [(<anonymous> + 1)]' to 'std::vector<long long int>'
   35 |     return ret;
      |            ^~~
      |            |
      |            long long int [(<anonymous> + 1)]