#include using namespace std; #define all(x) (x).begin(),(x).end() #define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr) #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 argc, char* argv[], char* envp[]) { int n, m; scanf("%d %d", &n, &m); vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } random_device seed_gen; mt19937 engine(seed_gen()); int bestScore = 0; vector bestState; int iter = 0; double startTime = getTime(); while (TIME_OUT > getTime() - startTime) { iter++; int score = 0; vector state(n); iota(all(state), 0); shuffle(all(state), engine); state.resize(m); for (int i = 0; i < m; i++) { int idx = state[i]; score ^= a[idx]; } if (bestScore < score) { bestScore = score; bestState = state; } } for (int i = 0; i < m; i++) { printf("%d%c", a[bestState[i]], (i + 1 == n ? '\n' : ' ')); } debug("time:%f iter:%d score:%d\n", getTime() - startTime, iter, bestScore); return 0; }