結果

問題 No.5001 排他的論理和でランニング
ユーザー trineutrontrineutron
提出日時 2022-05-15 16:29:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,451 ms / 1,500 ms
コード長 848 bytes
コンパイル時間 2,081 ms
実行使用メモリ 3,724 KB
スコア 51,380,175
最終ジャッジ日時 2022-05-15 16:30:33
合計ジャッジ時間 78,393 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,435 ms
3,460 KB
testcase_01 AC 1,413 ms
3,440 KB
testcase_02 AC 1,423 ms
3,468 KB
testcase_03 AC 1,436 ms
3,392 KB
testcase_04 AC 1,430 ms
3,448 KB
testcase_05 AC 1,414 ms
3,508 KB
testcase_06 AC 1,423 ms
3,388 KB
testcase_07 AC 1,433 ms
3,384 KB
testcase_08 AC 1,433 ms
3,436 KB
testcase_09 AC 1,417 ms
3,484 KB
testcase_10 AC 1,451 ms
3,628 KB
testcase_11 AC 1,434 ms
3,492 KB
testcase_12 AC 1,417 ms
3,624 KB
testcase_13 AC 1,427 ms
3,524 KB
testcase_14 AC 1,431 ms
3,700 KB
testcase_15 AC 1,434 ms
3,576 KB
testcase_16 AC 1,434 ms
3,560 KB
testcase_17 AC 1,432 ms
3,708 KB
testcase_18 AC 1,432 ms
3,464 KB
testcase_19 AC 1,424 ms
3,540 KB
testcase_20 AC 1,409 ms
3,724 KB
testcase_21 AC 1,431 ms
3,536 KB
testcase_22 AC 1,431 ms
3,484 KB
testcase_23 AC 1,431 ms
3,644 KB
testcase_24 AC 1,431 ms
3,552 KB
testcase_25 AC 1,427 ms
3,528 KB
testcase_26 AC 1,415 ms
3,460 KB
testcase_27 AC 1,415 ms
3,516 KB
testcase_28 AC 1,430 ms
3,700 KB
testcase_29 AC 1,436 ms
3,556 KB
testcase_30 AC 1,435 ms
3,492 KB
testcase_31 AC 1,424 ms
3,500 KB
testcase_32 AC 1,412 ms
3,624 KB
testcase_33 AC 1,435 ms
3,500 KB
testcase_34 AC 1,438 ms
3,452 KB
testcase_35 AC 1,434 ms
3,516 KB
testcase_36 AC 1,435 ms
3,464 KB
testcase_37 AC 1,434 ms
3,472 KB
testcase_38 AC 1,433 ms
3,552 KB
testcase_39 AC 1,434 ms
3,512 KB
testcase_40 AC 1,411 ms
3,384 KB
testcase_41 AC 1,431 ms
3,424 KB
testcase_42 AC 1,431 ms
3,456 KB
testcase_43 AC 1,410 ms
3,492 KB
testcase_44 AC 1,428 ms
3,392 KB
testcase_45 AC 1,433 ms
3,560 KB
testcase_46 AC 1,434 ms
3,448 KB
testcase_47 AC 1,435 ms
3,460 KB
testcase_48 AC 1,433 ms
3,608 KB
testcase_49 AC 1,436 ms
3,520 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];
	}
	vector<bool> used(n), best_used(n);
	int score = 0, best = 0;
	for (int i = 0; i < m; i++) {
		used[i] = true;
		score ^= a[i];
	}
	best_used = used;
	best = score;
	while (clock() - start < 1.4 * CLOCKS_PER_SEC) {
		int x = rng() % n;
		for (int i = 0; i < n; i++) {
			int y = i;
			if (used[x] == used[y]) continue;
			swap(used[x], used[y]);
			score ^= a[x] ^ a[y];
			if (score > best) {
				best_used = used;
				best = score;
			}
		}
	}
	int count = m;
	for (int i = 0; i < n; i++) {
		if (best_used[i]) {
			cout << a[i];
			m--;
			if (m) cout << ' ';
		}
	}
	cout << endl;
}
0