結果
問題 | No.130 XOR Minimax |
ユーザー | masa |
提出日時 | 2015-09-15 01:29:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 524 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 58,984 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-26 11:58:57 |
合計ジャッジ時間 | 3,195 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 17 ms
4,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 29 ms
4,380 KB |
testcase_07 | WA | - |
testcase_08 | AC | 40 ms
4,380 KB |
testcase_09 | AC | 6 ms
4,380 KB |
testcase_10 | AC | 8 ms
4,376 KB |
testcase_11 | WA | - |
testcase_12 | AC | 4 ms
4,380 KB |
testcase_13 | AC | 20 ms
4,380 KB |
testcase_14 | AC | 34 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 24 ms
4,376 KB |
testcase_17 | AC | 25 ms
4,376 KB |
testcase_18 | AC | 27 ms
4,376 KB |
testcase_19 | AC | 32 ms
4,376 KB |
testcase_20 | AC | 16 ms
4,376 KB |
testcase_21 | AC | 34 ms
4,376 KB |
testcase_22 | WA | - |
testcase_23 | AC | 4 ms
4,380 KB |
ソースコード
#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; }