結果

問題 No.5001 排他的論理和でランニング
ユーザー trineutrontrineutron
提出日時 2022-05-15 15:59:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,439 ms / 1,500 ms
コード長 850 bytes
コンパイル時間 1,844 ms
実行使用メモリ 4,888 KB
スコア 52,428,699
最終ジャッジ日時 2022-05-15 16:01:03
合計ジャッジ時間 78,761 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,435 ms
3,408 KB
testcase_01 AC 1,431 ms
3,600 KB
testcase_02 AC 1,431 ms
3,516 KB
testcase_03 AC 1,433 ms
3,548 KB
testcase_04 AC 1,427 ms
3,464 KB
testcase_05 AC 1,414 ms
3,672 KB
testcase_06 AC 1,428 ms
3,516 KB
testcase_07 AC 1,432 ms
3,708 KB
testcase_08 AC 1,436 ms
3,520 KB
testcase_09 AC 1,431 ms
3,540 KB
testcase_10 AC 1,433 ms
3,484 KB
testcase_11 AC 1,417 ms
3,388 KB
testcase_12 AC 1,433 ms
3,504 KB
testcase_13 AC 1,439 ms
4,888 KB
testcase_14 AC 1,434 ms
3,696 KB
testcase_15 AC 1,434 ms
3,564 KB
testcase_16 AC 1,435 ms
3,508 KB
testcase_17 AC 1,425 ms
3,584 KB
testcase_18 AC 1,413 ms
3,444 KB
testcase_19 AC 1,428 ms
3,468 KB
testcase_20 AC 1,435 ms
3,548 KB
testcase_21 AC 1,434 ms
3,620 KB
testcase_22 AC 1,413 ms
3,468 KB
testcase_23 AC 1,423 ms
3,560 KB
testcase_24 AC 1,434 ms
3,512 KB
testcase_25 AC 1,436 ms
3,520 KB
testcase_26 AC 1,431 ms
3,472 KB
testcase_27 AC 1,432 ms
3,536 KB
testcase_28 AC 1,434 ms
3,492 KB
testcase_29 AC 1,431 ms
3,556 KB
testcase_30 AC 1,411 ms
3,492 KB
testcase_31 AC 1,427 ms
3,544 KB
testcase_32 AC 1,434 ms
3,532 KB
testcase_33 AC 1,437 ms
3,400 KB
testcase_34 AC 1,437 ms
3,404 KB
testcase_35 AC 1,419 ms
3,400 KB
testcase_36 AC 1,423 ms
3,548 KB
testcase_37 AC 1,434 ms
3,400 KB
testcase_38 AC 1,433 ms
3,612 KB
testcase_39 AC 1,436 ms
3,608 KB
testcase_40 AC 1,434 ms
3,552 KB
testcase_41 AC 1,432 ms
3,536 KB
testcase_42 AC 1,420 ms
3,692 KB
testcase_43 AC 1,422 ms
3,460 KB
testcase_44 AC 1,433 ms
3,400 KB
testcase_45 AC 1,436 ms
3,560 KB
testcase_46 AC 1,433 ms
3,528 KB
testcase_47 AC 1,434 ms
3,492 KB
testcase_48 AC 1,436 ms
3,596 KB
testcase_49 AC 1,438 ms
3,504 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;
	uniform_int_distribution<> dist(0, n - 1);
	while (clock() - start < 1.4 * CLOCKS_PER_SEC) {
		int x = rng() % n, y = rng() % n;
		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