結果

問題 No.130 XOR Minimax
ユーザー tubo28tubo28
提出日時 2015-06-20 14:23:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 155 ms / 5,000 ms
コード長 601 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 61,936 KB
実行使用メモリ 56,416 KB
最終ジャッジ日時 2023-10-10 00:08:53
合計ジャッジ時間 3,135 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
6,952 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 69 ms
56,416 KB
testcase_05 AC 95 ms
56,328 KB
testcase_06 AC 73 ms
32,708 KB
testcase_07 AC 81 ms
31,700 KB
testcase_08 AC 155 ms
12,068 KB
testcase_09 AC 16 ms
7,584 KB
testcase_10 AC 21 ms
10,044 KB
testcase_11 AC 65 ms
27,880 KB
testcase_12 AC 8 ms
5,492 KB
testcase_13 AC 56 ms
22,828 KB
testcase_14 AC 135 ms
10,976 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 93 ms
8,252 KB
testcase_17 AC 98 ms
8,632 KB
testcase_18 AC 105 ms
9,112 KB
testcase_19 AC 130 ms
10,360 KB
testcase_20 AC 64 ms
6,732 KB
testcase_21 AC 129 ms
10,836 KB
testcase_22 AC 32 ms
4,716 KB
testcase_23 AC 10 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0