結果

問題 No.1240 Or Sum of Xor Pair
コンテスト
ユーザー tatyam
提出日時 2020-08-23 21:34:13
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 991 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,088 ms
コンパイル使用メモリ 228,460 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2026-06-12 20:32:19
合計ジャッジ時間 9,071 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1 -- * 2
other -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
using uint = uint32_t;
using ull = uint64_t;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const uint w = 1 << 9, mx = (200000 + w - 1) / w;
    uint a[mx] = {};
    uint n, x;
    cin >> n >> x;
    for(uint i = 0; i < n; i++) cin >> a[i];
    ull ans = 0;
    for(uint ib = 0; ib < mx; ib += w) for(uint jb = ib + w; jb < mx; jb += w)
        for(uint i = ib; i < ib + w; i++) for(uint j = jb; j < jb + w; j++)
            if(const uint b = a[i] ^ a[j]; b < x) ans += b;
    for(uint ib = 0; ib < mx; ib += w)
        for(uint i = ib; i < ib + w; i++) for(uint j = i + 1; j < ib + w; j++)
            if(const uint b = a[i] ^ a[j]; b < x) ans += b;
    for(uint i = 0; i < mx; i++) if(a[i] < x) ans -= ull(a[i]) * (mx - n);
    cout << ans << '\n';
}
0