結果

問題 No.130 XOR Minimax
ユーザー pekempeypekempey
提出日時 2015-08-20 19:52:15
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 769 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 147,876 KB
実行使用メモリ 29,304 KB
最終ジャッジ日時 2023-09-25 13:56:08
合計ジャッジ時間 9,522 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int N;

int dfs(int k, vector<int> A) {
	if (k < 0) return 0;
	vector<int> X, Y;
	rep (i, N) {
		if (A[i] & 1 << k) {
			X.push_back(A[i]);
		} else {
			Y.push_back(A[i]);
		}
	}
	if (X.size() == 0 || Y.size() == 0) {
		return dfs(k - 1, A);
	} else {
		return min(dfs(k - 1, X), dfs(k - 1, Y)) + (1 << k);
	}
}

int main() {
    cin >> N;
    vector<int> A(N);
    rep (i, N) cin >> A[i];

    cout << dfs(31, A) << endl;

    return 0;
}
0