제출 #737372

#제출 시각아이디문제언어결과실행 시간메모리
737372yellowtoad순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; int[] construct_permutation(int64 k) { long long int n = k, cnt = 1, sz, a[110]; for (int i = 1; i <= 100; i++) a[i] = 0; while ((1LL<<cnt)-1 <= n) cnt++; cnt--; sz = cnt; n -= (1LL<<cnt)-1; for (int i = 1; i <= cnt; i++) a[i] = i-1; while (cnt >= 0) { if ((1LL<<cnt) <= n) { n -= (1LL<<cnt); for (int i = sz; i >= 1; i--) a[i+1] = a[i]; sz++; if (cnt) a[1] = a[sz-cnt+1]; else a[1] = a[sz]+1; for (int i = sz; i >= sz-cnt+1; i--) a[i]++; } cnt--; } long long ans[sz]; for (int i = 0; i < sz; i++) ans[i] = a[i+1]; return ans[i]; } /*int main() { long long int k, b[]; cin >> k; b = construct_permutation(int64 k); for (int i = 0; i < sz; i++) cout << b[i] << " "; }*/

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

perm.cpp:4:4: error: structured binding declaration cannot have type 'int'
    4 | int[] construct_permutation(int64 k) {
      |    ^~
perm.cpp:4:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
perm.cpp:4:4: error: empty structured binding declaration
perm.cpp:4:7: error: expected initializer before 'construct_permutation'
    4 | int[] construct_permutation(int64 k) {
      |       ^~~~~~~~~~~~~~~~~~~~~