結果

問題 No.130 XOR Minimax
ユーザー IKyoproIKyopro
提出日時 2020-01-11 01:45:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 951 bytes
コンパイル時間 2,119 ms
コンパイル使用メモリ 202,892 KB
実行使用メモリ 28,216 KB
最終ジャッジ日時 2023-10-10 00:25:35
合計ジャッジ時間 4,047 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 71 ms
28,128 KB
testcase_05 AC 78 ms
28,216 KB
testcase_06 AC 72 ms
16,120 KB
testcase_07 AC 76 ms
15,672 KB
testcase_08 AC 47 ms
5,696 KB
testcase_09 AC 13 ms
5,088 KB
testcase_10 AC 20 ms
6,116 KB
testcase_11 AC 69 ms
14,004 KB
testcase_12 AC 7 ms
4,460 KB
testcase_13 AC 57 ms
11,976 KB
testcase_14 AC 54 ms
5,300 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 36 ms
4,572 KB
testcase_17 AC 39 ms
4,740 KB
testcase_18 AC 41 ms
4,880 KB
testcase_19 AC 50 ms
5,212 KB
testcase_20 AC 24 ms
4,352 KB
testcase_21 AC 52 ms
5,148 KB
testcase_22 AC 11 ms
4,352 KB
testcase_23 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> A(N);
    int h = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        for(int j=0;j<30;j++) if(A[i]&(1<<j)) h = j;
    }

    auto calc = [&](auto&& self,vec<ll>& A,int bit)->ll{
        bool ok = true;
        int n = A.size();
        if(n<=1 || bit<0) return 0;
        vec<ll> X,Y;
        for(int i=0;i<n;i++){
            if(A[i]&(1<<bit)) X.push_back(A[i]%(1<<bit));
            else Y.push_back(A[i]%(1<<bit));
        }
        if(X.empty() || Y.empty()) return (X.empty()? self(self,Y,bit-1):self(self,X,bit-1));
        else return (1<<bit) + min(self(self,X,bit-1),self(self,Y,bit-1));
    };
    cout << calc(calc,A,29) << endl;
}
0