結果

問題 No.130 XOR Minimax
ユーザー 沙耶花沙耶花
提出日時 2021-10-27 00:04:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 212 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 4,202 ms
コンパイル使用メモリ 261,324 KB
実行使用メモリ 28,420 KB
最終ジャッジ日時 2023-07-28 16:10:17
合計ジャッジ時間 7,531 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
4,536 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 45 ms
28,280 KB
testcase_05 AC 71 ms
28,420 KB
testcase_06 AC 66 ms
16,700 KB
testcase_07 AC 77 ms
16,232 KB
testcase_08 AC 212 ms
6,552 KB
testcase_09 AC 16 ms
5,460 KB
testcase_10 AC 23 ms
6,620 KB
testcase_11 AC 68 ms
14,648 KB
testcase_12 AC 9 ms
4,556 KB
testcase_13 AC 57 ms
12,080 KB
testcase_14 AC 191 ms
5,864 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 137 ms
4,964 KB
testcase_17 AC 143 ms
5,300 KB
testcase_18 AC 152 ms
5,344 KB
testcase_19 AC 180 ms
5,784 KB
testcase_20 AC 92 ms
4,380 KB
testcase_21 AC 189 ms
5,772 KB
testcase_22 AC 44 ms
4,376 KB
testcase_23 AC 15 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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(b==2){
		cout<<get(x[1],b-1)<<endl;
	}
	*/
	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