# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
916501 |
2024-01-26T02:41:25 Z |
wii |
Permutation (APIO22_perm) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include <perm.h>
using namespace std;
#define int long long
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());
}
Compilation message
perm.cpp:19:13: error: ambiguating new declaration of 'std::vector<long long int> construct_permutation(long long int)'
19 | vector<int> construct_permutation(int k) {
| ^~~~~~~~~~~~~~~~~~~~~
In file included from perm.cpp:2:
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:23:30: warning: operation on 'x' may be undefined [-Wsequence-point]
23 | for (int x = k; x > 0; x = (~x & 1 ? --x : x >> 1), ++cnt);
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~
perm.cpp:23:30: warning: operation on 'x' may be undefined [-Wsequence-point]