結果

問題 No.130 XOR Minimax
ユーザー matsukin1111matsukin1111
提出日時 2019-06-13 21:58:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 5,000 ms
コード長 1,449 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 104,100 KB
実行使用メモリ 21,312 KB
最終ジャッジ日時 2023-10-10 00:24:32
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
6,644 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 15 ms
4,348 KB
testcase_05 AC 41 ms
4,348 KB
testcase_06 AC 95 ms
21,312 KB
testcase_07 AC 105 ms
20,800 KB
testcase_08 AC 94 ms
11,144 KB
testcase_09 AC 15 ms
5,988 KB
testcase_10 AC 22 ms
6,996 KB
testcase_11 AC 74 ms
13,700 KB
testcase_12 AC 8 ms
4,704 KB
testcase_13 AC 62 ms
12,132 KB
testcase_14 AC 102 ms
9,696 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 66 ms
7,860 KB
testcase_17 AC 70 ms
8,120 KB
testcase_18 AC 78 ms
8,452 KB
testcase_19 AC 97 ms
9,348 KB
testcase_20 AC 40 ms
6,116 KB
testcase_21 AC 97 ms
9,732 KB
testcase_22 AC 18 ms
4,688 KB
testcase_23 AC 6 ms
4,356 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<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(30,v) << endl;
	return 0;
}
0