Submission #916499

#TimeUsernameProblemLanguageResultExecution timeMemory
916499wiiPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <perm.h> using namespace std; void dnc(deque<int> &v, int id, int u) { if (id < 0) return; if (u & 1) { dnc(v, id - 1, u >> 1); v.push_back(id); } else { dnc(v, id - 1, u - 1); v.push_front(id); } } vector<int> construct_permutation(int k) { k -= 1; int cnt = 0; for (int x = k; x > 0; x = (~x & 1 ? --x : x >> 1), ++cnt); deque<int> ans; dnc(ans, cnt - 1, k); return vector<int>(ans.begin(), ans.end()); } signed main() { int k; cin >> k; vector<int> ans; ans = construct_permutation(k); for (int u: ans) cout << u << " "; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(int)':
perm.cpp:22:30: warning: operation on 'x' may be undefined [-Wsequence-point]
   22 |     for (int x = k; x > 0; x = (~x & 1 ? --x : x >> 1), ++cnt);
      |                            ~~^~~~~~~~~~~~~~~~~~~~~~~~~
perm.cpp:22:30: warning: operation on 'x' may be undefined [-Wsequence-point]
/usr/bin/ld: /tmp/ccNqaA3f.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccP653Jf.o:perm.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccNqaA3f.o: in function `main':
grader.cpp:(.text.startup+0x240): undefined reference to `construct_permutation(long long)'
collect2: error: ld returned 1 exit status