結果

問題 No.5001 排他的論理和でランニング
ユーザー ldsyb
提出日時 2018-03-24 10:54:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,408 ms / 1,500 ms
コード長 669 bytes
コンパイル時間 1,722 ms
実行使用メモリ 7,424 KB
スコア 52,428,748
最終ジャッジ日時 2020-03-12 20:22:05
ジャッジサーバーID
(参考情報)
judge10 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	auto start = system_clock::now();
	random_device rnd;
	mt19937 mt(rnd());
	int n, m;
	cin >> n >> m;
	int a[n];
	uniform_int_distribution<> rand(0, n - 1);
	for (auto &i : a) {
		cin >> i;
	}
	if (m < n) {
		int d = n - m, x = 0;
		for (int i = 0; i < m; i++) {
			x ^= a[i];
		}
		while (duration_cast<milliseconds>(system_clock::now() - start).count() < 1400) {
			int i = rand(mt) % m, j = rand(mt) % d + m;
			int y = x ^ a[i] ^ a[j];
			if (x < y) {
				x = y;
				swap(a[i], a[j]);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		cout << a[i] << ' ';
	}
	cout << endl;
	return 0;
}
0