結果

問題 No.130 XOR Minimax
ユーザー 👑 jupirojupiro
提出日時 2020-01-11 00:15:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 120,244 KB
実行使用メモリ 10,904 KB
最終ジャッジ日時 2023-08-15 14:45:19
合計ジャッジ時間 3,993 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 38 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll N;
set<ll> S;
vector<ll> v;

int hoge(ll d, vector<ll>& v) {
	if (v.size() <= 1) return 0;
	int i, j;
	vector<ll> w[2];
	for (ll i = 0; i < v.size(); i++) {
		int x = v[i];
		w[(x >> d) & 1].push_back(x ^ (x&(1 << d)));
	}

	if (w[0].size() == 0) return hoge(d - 1, w[1]);
	if (w[1].size() == 0) return hoge(d - 1, w[0]);

	return (1 << d) + min(hoge(d - 1, w[0]), hoge(d - 1, w[1]));
}

void solve() {
	string s;
	cin >> N;
	ll x;
	for(ll i=0;i<N;i++) cin >> x, S.insert(x);
	for(auto p : S) v.push_back(p);

	cout << hoge(40, v) << endl;
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	solve();
	return 0;
}
0