結果

問題 No.130 XOR Minimax
ユーザー matsukin1111matsukin1111
提出日時 2019-06-13 21:58:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 102,648 KB
実行使用メモリ 16,648 KB
最終ジャッジ日時 2023-08-05 19:14:22
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 15 ms
4,376 KB
testcase_05 AC 41 ms
4,376 KB
testcase_06 AC 93 ms
16,264 KB
testcase_07 WA -
testcase_08 AC 95 ms
12,600 KB
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<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

vector<int>v;
set<int>st;
int N;

int calc(int d, vector<int>li) {
	if (li.size() <= 1)return 0;
	vector<int>w[2];
	rep(i, 0, li.size()) {
		int x = li[i];
		if (x & (1 << d)) {
			w[1].pb(x^(1<<d));
		}
		else {
			w[0].pb(x);
		}
	}
	if (w[0].size() == 0)return calc(d-1,w[1]);
	if (w[1].size() == 0)return calc(d-1,w[0]);
	int ret = 1 << d;
	ret += min(calc(d-1,w[0]), calc(d-1,w[1]));
	return ret;
}

int main(){
	cin >> N;
	rep(i, 0, N) {
		int x;
		cin >> x;
		st.insert(x);
	}
	fore(x, st)v.pb(x);
	cout << calc(32,v) << endl;
	return 0;
}
0