結果

問題 No.1082 XORのXOR
ユーザー hotaru
提出日時 2020-06-19 22:26:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 85,432 KB
最終ジャッジ日時 2025-01-11 06:59:51
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

// XはA_1⊕A_{N-1}となる
// A_1とA_{N-1}の組を全探索

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int maxval = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            const int val = a[i] ^ a[j];
            if (val >= maxval) {
                maxval = val;
            }
        }
    }

    const int ans = maxval;
    cout << ans << endl;
}
0