結果

問題 No.130 XOR Minimax
ユーザー hotpepsihotpepsi
提出日時 2016-01-11 02:01:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 59,352 KB
実行使用メモリ 4,840 KB
最終ジャッジ日時 2023-10-19 22:43:53
合計ジャッジ時間 41,287 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,828 KB
testcase_03 AC 2 ms
4,828 KB
testcase_04 AC 1,587 ms
4,828 KB
testcase_05 AC 3,191 ms
4,828 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	int A[100000], H[100000], L[100000], f = 0, h = 0, l = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		H[i] = A[i] >> 15, L[i] = A[i] & ((1 << 15) - 1);
		f |= H[i], h ^= H[i], l ^= L[i];
	}
	int lm = 1 << 30;
	for (int b = 1; b < (1 << 15); ++b) {
		int x = 0;
		for (int i = 0; i < N; ++i) {
			x ^= L[i];
		}
		lm = min(lm, x);
	}
	int ans = lm;
	if (f) {
		int hm = 1 << 30;
		for (int b = 1; b < (1 << 15); ++b) {
			int x = 0;
			for (int i = 0; i < N; ++i) {
				x ^= H[i];
			}
			hm = min(hm, x);
		}
		if (h < hm) {
			ans = (h << 15) | lm;
		} else if (l < lm) {
			ans = (hm << 15) | l;
		} else {
			ans = (hm << 15) | lm;
		}
	}
	cout << ans << endl;
	return 0;
}
0