#include using namespace std; #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define INLINE inline __attribute__ ((always_inline)) constexpr double TIME_OUT = 1.45; constexpr double CYCLES_PER_SEC = 2.6 * 1e9; INLINE int64_t getCycle() { uint32_t low, high; __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); return ((int64_t)low) | ((int64_t)high << 32); } INLINE static double getTime() { return getCycle() / CYCLES_PER_SEC; } int main() { int n, m; scanf("%d %d", &n, &m); vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(rall(a)); random_device seed_gen; mt19937 engine(seed_gen()); int score = 0; vector state(n); iota(all(state), 0); int bestScore = 0; vector bestState(m); double startTime = getTime(); while (TIME_OUT > getTime() - startTime) { score = 0; for (int i = 0; i < m; i++) { score ^= a[state[i]]; } if (bestScore < score) { bestScore = score; for (int i = 0; i < m; i++) { bestState[i] = state[i]; } } shuffle(all(state), engine); } for (int i = 0; i < m; i++) { printf("%d%c", a[bestState[i]], (i + 1 == n ? '\n' : ' ')); } return 0; }