結果

問題 No.130 XOR Minimax
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-24 05:41:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 1,235 ms
コンパイル使用メモリ 145,000 KB
実行使用メモリ 15,800 KB
最終ジャッジ日時 2024-04-29 04:48:27
合計ジャッジ時間 3,772 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 38 ms
15,672 KB
testcase_05 AC 65 ms
15,800 KB
testcase_06 AC 52 ms
9,528 KB
testcase_07 AC 65 ms
9,392 KB
testcase_08 AC 109 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 55 ms
8,696 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 46 ms
7,556 KB
testcase_14 AC 109 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 77 ms
5,376 KB
testcase_17 AC 81 ms
5,376 KB
testcase_18 AC 86 ms
5,376 KB
testcase_19 AC 102 ms
5,376 KB
testcase_20 AC 52 ms
5,376 KB
testcase_21 AC 107 ms
5,376 KB
testcase_22 AC 26 ms
5,376 KB
testcase_23 AC 9 ms
5,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