Submission #912490

#TimeUsernameProblemLanguageResultExecution timeMemory
912490linvgPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
int[] construct_permutation(int64_t x) { int64_t sum = 1; int64_t mn = 1e9 - 1; vector<int64_t> res; while (sum < x) { int64_t cnt = 0; for (int64_t i = 1; i <= 62; ++i) { if (sum + (1ll << i) - 1 > x) { sum += (1ll << (i-1)) - 1; cnt = i - 1; break; } } // dbg(sum, cnt); for (int64_t i = mn - cnt; i < mn; ++i) { // cout << i << " "; res.pb(i); } mn -= cnt; for (int64_t i = 62; i >= 1; --i) { if (sum + (1ll << (i - 1)) <= x) { sum += (1ll << (i - 1)); cnt = i - 1; res.pb(mn + cnt); } } } // dbg(sum); // dbg(sz(res)); int ans[sz(res)] = {0}; for (int64_t i = 0; i < sz(res); ++i) { ans[i] = res[i]; } return ans; }

Compilation message (stderr)

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