結果
問題 |
No.5001 排他的論理和でランニング
|
ユーザー |
|
提出日時 | 2018-03-17 16:08:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 326 ms / 1,500 ms |
コード長 | 852 bytes |
コンパイル時間 | 584 ms |
実行使用メモリ | 7,420 KB |
スコア | 52,428,654 |
最終ジャッジ日時 | 2020-03-12 20:13:08 |
ジャッジサーバーID (参考情報) |
judge6 / |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <stdio.h> #include <time.h> #include <vector> #include <random> #include <algorithm> using namespace std; mt19937 mt(123); // [l,r] int randint(int l, int r) { return uniform_int_distribution<int>(l, r)(mt); } int main() { int n, m; scanf("%d %d", &n, &m); vector<int> a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } int ans_x = 0; vector<int> ans_a; clock_t start = clock(); int x = 0; for (int i = 0; i < m; i++) { x ^= a[i]; } ans_x = x; ans_a = a; while (double(clock() - start) / CLOCKS_PER_SEC < 0.3) { int i = randint(0, m - 1); int j = randint(m, n - 1); x ^= a[i] ^ a[j]; swap(a[i], a[j]); if (ans_x < x) { ans_x = x; ans_a = a; } } for (int i = 0; i < m; i++) { if (i > 0) putchar(' '); printf("%d", ans_a[i]); } puts(""); }