結果

問題 No.130 XOR Minimax
ユーザー IKyoproIKyopro
提出日時 2020-01-11 01:38:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 206,168 KB
実行使用メモリ 51,884 KB
最終ジャッジ日時 2024-05-03 02:08:21
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
6,820 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 12 ms
6,944 KB
testcase_05 AC 89 ms
51,884 KB
testcase_06 AC 52 ms
8,076 KB
testcase_07 AC 87 ms
27,672 KB
testcase_08 AC 55 ms
8,008 KB
testcase_09 AC 11 ms
6,944 KB
testcase_10 AC 16 ms
6,944 KB
testcase_11 AC 50 ms
7,400 KB
testcase_12 WA -
testcase_13 AC 40 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 41 ms
6,944 KB
testcase_17 AC 44 ms
6,940 KB
testcase_18 AC 47 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 28 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 12 ms
6,940 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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,h) << endl;
}
0