結果

問題 No.130 XOR Minimax
ユーザー なおなお
提出日時 2015-01-16 23:58:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 632 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 144,056 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-04 14:42:58
合計ジャッジ時間 3,501 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 22 ms
4,384 KB
testcase_05 AC 49 ms
4,384 KB
testcase_06 AC 35 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 45 ms
4,380 KB
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 9 ms
4,384 KB
testcase_11 WA -
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 23 ms
4,380 KB
testcase_14 AC 38 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 27 ms
4,380 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 30 ms
4,384 KB
testcase_19 AC 35 ms
4,384 KB
testcase_20 AC 18 ms
4,384 KB
testcase_21 AC 38 ms
4,384 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,384 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;
        for(int k = 1; k <= 3; k++){
            int mask = s | (k<<i);
            REP(j,N){
                v = max(v, A[j] ^ mask);
            }
            if(v < maxv){
                maxv = v;
                s = mask;
            }
        }
    }
    cerr << s << endl;
    cout << maxv << endl;
}
0