結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2016-07-06 20:58:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 490 bytes |
コンパイル時間 | 637 ms |
コンパイル使用メモリ | 59,244 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-12 22:40:49 |
合計ジャッジ時間 | 2,217 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream>#include <algorithm>#define int long longusing namespace std;int n;int a[100000];//[l, r)int dfs(int l, int r, int ind) {if (ind < 0) return 0;int i;for (i = l; i < r; i++) if ((a[i] >> ind) % 2) break;if (i == l || i == r) return dfs(l, r, ind - 1);return (1LL << ind) + min(dfs(l, i, ind - 1), dfs(i, r, ind - 1));}signed main() {cin >> n;for (int i = 0; i < n; i++) cin >> a[i];sort(a, a + n);cout << dfs(0, n, 35) << endl;return 0;}