#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)) using ll = long long; using ull = unsigned long long; using pll = pair; using mt = tuple; using vll = vector; using vpll = vector; using vmt = vector; constexpr double TIME_OUT = 1.2; constexpr double CYCLES_PER_SEC = 2.8 * 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; } INLINE static uint32_t xor128(void) { static uint32_t x = 123456789, y = 362436069, z = 521288629, w = 88675123; uint32_t t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } INLINE static double getRand() { return (double) xor128() / (1LL << 32); } int main(int argc, char* argv[], char* envp[]) { ll n, m; scanf("%lld %lld", &n, &m); vll a(n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } int bestScore = 0; set bestState; int iter = 0; double startTime = getTime(); while (TIME_OUT > getTime() - startTime) { iter++; int score = 0; set used; int remain = m; while (0 < remain) { int idx; while (true) { idx = xor128() % n; if (0 == used.count(idx)) { used.insert(idx); break; } } score ^= a[idx]; remain--; } if (bestScore < score) { bestScore = score; bestState = used; } } vll ans(all(bestState)); for (int i = 0; i < m; i++) { printf("%lld%c", a[ans[i]], (i + 1 == n ? '\n' : ' ')); } debug("time:%f iter:%d score:%d\n", getTime() - startTime, iter, bestScore); return 0; }