結果

問題 No.5001 排他的論理和でランニング
ユーザー trineutrontrineutron
提出日時 2022-05-15 16:40:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,450 ms / 1,500 ms
コード長 783 bytes
コンパイル時間 1,745 ms
実行使用メモリ 6,952 KB
スコア 51,380,163
最終ジャッジ日時 2022-05-15 16:41:47
合計ジャッジ時間 78,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,424 ms
4,904 KB
testcase_01 AC 1,431 ms
4,900 KB
testcase_02 AC 1,431 ms
5,456 KB
testcase_03 AC 1,427 ms
4,904 KB
testcase_04 AC 1,415 ms
3,768 KB
testcase_05 AC 1,425 ms
4,900 KB
testcase_06 AC 1,430 ms
4,904 KB
testcase_07 AC 1,430 ms
4,904 KB
testcase_08 AC 1,434 ms
4,900 KB
testcase_09 AC 1,428 ms
4,900 KB
testcase_10 AC 1,433 ms
5,160 KB
testcase_11 AC 1,432 ms
5,160 KB
testcase_12 AC 1,417 ms
4,904 KB
testcase_13 AC 1,419 ms
4,908 KB
testcase_14 AC 1,432 ms
4,904 KB
testcase_15 AC 1,431 ms
4,904 KB
testcase_16 AC 1,425 ms
4,900 KB
testcase_17 AC 1,416 ms
4,900 KB
testcase_18 AC 1,432 ms
4,904 KB
testcase_19 AC 1,430 ms
5,160 KB
testcase_20 AC 1,430 ms
5,160 KB
testcase_21 AC 1,430 ms
5,156 KB
testcase_22 AC 1,429 ms
4,908 KB
testcase_23 AC 1,429 ms
4,900 KB
testcase_24 AC 1,413 ms
4,900 KB
testcase_25 AC 1,423 ms
4,904 KB
testcase_26 AC 1,432 ms
4,908 KB
testcase_27 AC 1,429 ms
4,904 KB
testcase_28 AC 1,421 ms
4,904 KB
testcase_29 AC 1,418 ms
4,904 KB
testcase_30 AC 1,430 ms
4,904 KB
testcase_31 AC 1,432 ms
6,952 KB
testcase_32 AC 1,425 ms
5,156 KB
testcase_33 AC 1,434 ms
5,156 KB
testcase_34 AC 1,435 ms
4,900 KB
testcase_35 AC 1,434 ms
4,904 KB
testcase_36 AC 1,417 ms
4,904 KB
testcase_37 AC 1,417 ms
4,904 KB
testcase_38 AC 1,438 ms
4,900 KB
testcase_39 AC 1,433 ms
6,948 KB
testcase_40 AC 1,429 ms
4,904 KB
testcase_41 AC 1,450 ms
4,904 KB
testcase_42 AC 1,431 ms
4,908 KB
testcase_43 AC 1,423 ms
4,904 KB
testcase_44 AC 1,413 ms
3,764 KB
testcase_45 AC 1,431 ms
4,900 KB
testcase_46 AC 1,431 ms
6,948 KB
testcase_47 AC 1,424 ms
4,900 KB
testcase_48 AC 1,432 ms
4,908 KB
testcase_49 AC 1,428 ms
6,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

uint64_t rng() {
	static uint64_t x = 1;
	x ^= x << 9;
	return x ^= x >> 7;
}

int main() {
	clock_t start = clock();
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int score = 0, best = 0;
	for (int i = 0; i < m; i++) {
		score ^= a[i];
	}
	vector<int> ans(m);
	copy(a.begin(), a.begin() + m, ans.begin());
	best = score;
	while (clock() - start < 1.4 * CLOCKS_PER_SEC) {
		if (m == 0 or m == n) break;
		int x = rng() % m, y = rng() % (n - m) + m;
		score ^= a[x] ^ a[y];
		swap(a[x], a[y]);
		if (score > best) {
			copy(a.begin(), a.begin() + m, ans.begin());
			best = score;
		}
	}
	for (int i = 0; i < m; i++) {
		cout << ans[i];
		if (i < m - 1) cout << ' ';
	}
	cout << endl;
}
0