結果

問題 No.130 XOR Minimax
ユーザー matsukin1111matsukin1111
提出日時 2019-06-13 22:07:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 5,000 ms
コード長 1,436 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 104,224 KB
実行使用メモリ 42,944 KB
最終ジャッジ日時 2023-10-10 00:24:40
合計ジャッジ時間 4,342 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
11,148 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 15 ms
4,352 KB
testcase_05 AC 42 ms
4,348 KB
testcase_06 AC 122 ms
42,944 KB
testcase_07 AC 128 ms
41,828 KB
testcase_08 AC 215 ms
22,036 KB
testcase_09 AC 20 ms
8,828 KB
testcase_10 AC 31 ms
11,156 KB
testcase_11 AC 96 ms
25,952 KB
testcase_12 AC 11 ms
6,132 KB
testcase_13 AC 77 ms
22,348 KB
testcase_14 AC 205 ms
19,088 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 140 ms
14,384 KB
testcase_17 AC 144 ms
14,868 KB
testcase_18 AC 156 ms
15,564 KB
testcase_19 AC 189 ms
18,040 KB
testcase_20 AC 90 ms
10,504 KB
testcase_21 AC 203 ms
18,864 KB
testcase_22 AC 42 ms
6,384 KB
testcase_23 AC 14 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

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<ll>v;
set<ll>st;
ll N;

ll calc(ll d, vector<ll>li) {
	if (d == -1)return 0;
	vector<ll>w[2];
	rep(i, 0, li.size()) {
		ll x = li[i];
		if (x & (1LL << d)) {
			w[1].pb(x^(1LL<<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]);
	ll ret = 1LL << d;
	ret += min(calc(d-1,w[0]), calc(d-1,w[1]));
	return ret;
}

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