結果

問題 No.130 XOR Minimax
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-24 05:41:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 5,886 ms
コンパイル使用メモリ 107,760 KB
実行使用メモリ 15,596 KB
最終ジャッジ日時 2023-08-11 12:22:48
合計ジャッジ時間 4,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 35 ms
15,552 KB
testcase_05 AC 62 ms
15,596 KB
testcase_06 AC 51 ms
9,612 KB
testcase_07 AC 61 ms
9,420 KB
testcase_08 AC 105 ms
4,452 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 17 ms
4,792 KB
testcase_11 AC 54 ms
8,692 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 44 ms
7,544 KB
testcase_14 AC 108 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 75 ms
4,380 KB
testcase_17 AC 77 ms
4,380 KB
testcase_18 AC 83 ms
4,380 KB
testcase_19 AC 100 ms
4,376 KB
testcase_20 AC 50 ms
4,380 KB
testcase_21 AC 102 ms
4,384 KB
testcase_22 AC 24 ms
4,380 KB
testcase_23 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

int f(int n, vector<int> &S){
    if (n == -1) return 0;
    vector<int> S0, S1;
    for (int i=0; i<S.size(); i++){
        if (1<<n & S[i]) S1.push_back(S[i]);
        else S0.push_back(S[i]);
    }

    if (S1.size() == 0) return f(n-1, S0);
    else if (S0.size() == 0) return f(n-1, S1);

    return min(f(n-1, S0), f(n-1, S1)) + (1<<n);
}

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    cout << f(29, A) << endl;

    return 0;
}
0