結果

問題 No.130 XOR Minimax
ユーザー 沙耶花沙耶花
提出日時 2021-10-26 23:58:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 4,755 ms
コンパイル使用メモリ 254,992 KB
実行使用メモリ 28,484 KB
最終ジャッジ日時 2024-04-16 00:21:41
合計ジャッジ時間 7,875 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 49 ms
28,484 KB
testcase_05 AC 78 ms
28,476 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 <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

int get(vector<int> a,int b){
	if(a.size()==0)return 0;
	if(b==-1)return 0;
	vector<vector<int>> x(2);
	rep(i,a.size()){
		if((a[i]>>b)&1){
			x[1].push_back(a[i]^(1<<b));
		}
		else{
			x[0].push_back(a[i]);
		}
	}
	if(x[0].size()==0||x[1].size()==0){
		return max(get(x[0],b-1),get(x[1],b-1));
	}
	else{
		return min(get(x[0],b-1),get(x[1],b-1)) + 1<<b;
	}
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(N);
	rep(i,N)cin>>a[i];
	
	cout<<get(a,30)<<endl;
	
	return 0;
}
0