結果

問題 No.130 XOR Minimax
ユーザー matsukin1111matsukin1111
提出日時 2019-06-13 22:04:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,442 bytes
コンパイル時間 977 ms
コンパイル使用メモリ 103,792 KB
実行使用メモリ 22,364 KB
最終ジャッジ日時 2024-04-23 16:02:35
合計ジャッジ時間 3,225 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 16 ms
5,376 KB
testcase_05 AC 45 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 109 ms
22,364 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<ll>v;
set<ll>st;
int N;

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