結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-11 00:15:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,465 bytes |
| コンパイル時間 | 1,142 ms |
| コンパイル使用メモリ | 121,660 KB |
| 実行使用メモリ | 10,660 KB |
| 最終ジャッジ日時 | 2024-11-23 22:20:47 |
| 合計ジャッジ時間 | 3,464 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 19 |
ソースコード
#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;
}