結果
問題 |
No.130 XOR Minimax
|
ユーザー |
|
提出日時 | 2015-09-15 01:29:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 524 bytes |
コンパイル時間 | 536 ms |
コンパイル使用メモリ | 58,868 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 06:32:52 |
合計ジャッジ時間 | 2,481 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 5 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n, 0); for (int i = 0; i < n; i++) { cin >> a[i]; } int xx = 0; int max0, max1; for (int i = 20; i >= 0; i--) { int x0 = xx; int x1 = xx + (1 << i); max0 = 0; max1 = 0; for (int j = 0; j < n; j++) { max0 = max(max0, a[j] ^ x0); max1 = max(max1, a[j] ^ x1); } xx = max0 < max1 ? x0 : x1; } int ans = max0 < max1 ? max0 : max1; cout << ans << endl; return 0; }