結果

問題 No.130 XOR Minimax
ユーザー ctyl_0ctyl_0
提出日時 2015-11-04 16:44:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,488 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 88,972 KB
実行使用メモリ 27,428 KB
最終ジャッジ日時 2023-10-11 13:41:37
合計ジャッジ時間 3,381 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,476 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 37 ms
27,428 KB
testcase_05 AC 43 ms
27,368 KB
testcase_06 WA -
testcase_07 AC 44 ms
15,888 KB
testcase_08 AC 38 ms
6,424 KB
testcase_09 AC 9 ms
5,396 KB
testcase_10 AC 13 ms
6,356 KB
testcase_11 WA -
testcase_12 AC 5 ms
4,352 KB
testcase_13 AC 33 ms
12,204 KB
testcase_14 AC 43 ms
5,848 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 29 ms
4,900 KB
testcase_17 AC 31 ms
5,184 KB
testcase_18 AC 34 ms
5,276 KB
testcase_19 AC 40 ms
5,976 KB
testcase_20 AC 20 ms
4,428 KB
testcase_21 AC 42 ms
5,860 KB
testcase_22 AC 10 ms
4,352 KB
testcase_23 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << fixed << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template

int digit(int d, vector<int> v){ // 下から何桁目を見るか 10^9 < 1 << 30
    if (v.size() <= 1 || d == 0) {
        return 0;
    }
    
    vector<int> w[2]; //0: d桁目が0 1: d桁目が1
    rep(i, v.size()){
        int n = v[i];
        w[(n >> d) & 1].push_back(n ^ (n & (1 << d)));
    }
    
    if (w[0].empty()) {
        return digit(d - 1, w[1]);
    }
    if (w[1].empty()) {
        return digit(d - 1, w[0]);
    }
    
    return (1 << d) + min(digit(d - 1, w[0]), digit(d - 1, w[1]));
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    // source code
    
    int N = inputValue();
    vector<int> A(N);
    rep(i, N){
        A[i] = inputValue();
    }
    
    int ret = digit(30, A);
    output(ret, 0);
    
    return 0;
}
0