結果
問題 | No.130 XOR Minimax |
ユーザー |
|
提出日時 | 2021-02-26 19:45:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 141 ms / 5,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 1,976 ms |
コンパイル使用メモリ | 197,488 KB |
最終ジャッジ日時 | 2025-01-19 04:38:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;long long dfs(vector<long long> a, int d = 1<<30) {vector<long long> b, c;for (long long x: a) {if (x & d)b.push_back(x ^ d);elsec.push_back(x);}if (d == 1) return (b.size() && c.size()) ? 1 : 0;if (!c.size()) return dfs(b, d>>1);if (!b.size()) return dfs(c, d>>1);long long ret = min(dfs(b, d>>1), dfs(c, d>>1));return d | ret;}int main() {ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;vector<long long> a(n);for (int i = 0; i < n; i++)cin >> a[i];cout << dfs(a) << endl;return 0;}