結果

問題 No.130 XOR Minimax
ユーザー なおなお
提出日時 2015-01-16 23:53:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 2,874 ms
コンパイル使用メモリ 143,528 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 14:34:57
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 AC 43 ms
4,380 KB
testcase_06 AC 29 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 40 ms
4,380 KB
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 21 ms
4,376 KB
testcase_14 AC 34 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 24 ms
4,376 KB
testcase_17 AC 25 ms
4,376 KB
testcase_18 AC 26 ms
4,376 KB
testcase_19 AC 32 ms
4,380 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 33 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
int A[100100];
int main(){
    int N; cin >> N;
    int maxv = 0;
    REP(i,N){
        cin >> A[i];
        maxv = max(maxv, A[i]);
    }
    int s = 0;
    for(int i = 30; i >= 0; i--){
        int v = 0;
        int mask = s | 1<<i;
        REP(j,N){
            v = max(v, A[j] ^ mask);
        }
        if(v < maxv){
            maxv = v;
            s = mask;
        }
    }
    cerr << s << endl;
    cout << maxv << endl;
}
0