結果

問題 No.130 XOR Minimax
ユーザー mayoko_mayoko_
提出日時 2015-01-17 11:03:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 72,376 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-04 18:22:54
合計ジャッジ時間 3,296 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

const int MAXN = 100010;
int a[MAXN];
bool bit[64];

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < 32; i++) {
        bit[i] = true;
    }
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < N; j++) {
            if (((a[j] >> i) & 1) == 0) bit[i] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < 32; i++) {
        if (bit[i]) ans |= 1<<i;
    }
    int ret = 0;
    for (int i = 0; i < N; i++) {
        ret = max(a[i] ^ ans, ret);
    }
    cout << ret << endl;
    return 0;
}
0