結果

問題 No.130 XOR Minimax
ユーザー masamasa
提出日時 2015-09-15 01:35:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 59,244 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 11:59:17
合計ジャッジ時間 2,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 45 ms
4,380 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 42 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 4 ms
4,384 KB
testcase_13 AC 21 ms
4,380 KB
testcase_14 AC 36 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 26 ms
4,380 KB
testcase_17 AC 26 ms
4,376 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 33 ms
4,380 KB
testcase_20 AC 17 ms
4,380 KB
testcase_21 AC 35 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
	int n;

	cin >> n;
	vector<unsigned int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	unsigned int xx = 0;
	unsigned int max0, max1;
	for (int i = 30; i >= 0; i--) {
		 unsigned int x0 = xx;
		 unsigned int x1 = xx + (1 << i);
		 max0 = 0;
		 max1 = 0;
		for (int j = 0; j < n; j++) {
			max0 = max(max0, a[j] ^ x0);
			max1 = max(max1, a[j] ^ x1);
		}

		xx = max0 < max1 ? x0 : x1;
	}

	int unsigned ans = max0 < max1 ? max0 : max1;
	cout << ans << endl;
	return 0;
}
0