結果
問題 |
No.5001 排他的論理和でランニング
|
ユーザー |
![]() |
提出日時 | 2018-03-16 23:28:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 1,500 ms |
コード長 | 911 bytes |
コンパイル時間 | 749 ms |
実行使用メモリ | 5,384 KB |
スコア | 52,428,750 |
最終ジャッジ日時 | 2020-03-12 19:34:56 |
ジャッジサーバーID (参考情報) |
judge7 / |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <random> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n); int z = 0; for (int i = 0; i < n; i++) { cin >> a[i]; z |= a[i]; } int x = 0; for (int i = 0; i < m; i++) { x ^= a[i]; } int l = n - m; if (l > 0) { mt19937_64 rnd; for (int k = 0; k < 1 << 24; k++) { int i = rnd() % m; int j = rnd() % l + m; int y = x ^ a[i] ^ a[j]; if (y > x) { x = y; swap(a[i], a[j]); } if (x == z) break; } } for (int i = 0; i < m; i++) { cout << a[i] << " \n"[i == m - 1]; } return 0; }