結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2015-06-20 14:23:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 168 ms / 5,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 830 ms |
コンパイル使用メモリ | 64,080 KB |
実行使用メモリ | 56,688 KB |
最終ジャッジ日時 | 2024-09-12 22:35:14 |
合計ジャッジ時間 | 3,199 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long ll; #define loop(i,a,b) for(int i=(a);i<int(b);i++) #define rep(i,b) loop(i,0,b) ll solve(int b, vector<ll> a){ if(b < 0 || a.empty()) return 0; vector<ll> div[2]; for(ll x : a) div[x>>b&1].push_back(x); if(div[0].size()==0) return solve(b-1,div[1]); if(div[1].size()==0) return solve(b-1,div[0]); ll x = solve(b-1,div[0]), y = solve(b-1,div[1]); return 1<<b | min(x,y); } int main(){ int n; cin >> n; vector<ll> a(n); rep(i,n) cin >> a[i]; cout << solve(32,a) << endl; }