結果

問題 No.1240 Or Sum of Xor Pair
ユーザー beetbeet
提出日時 2020-09-26 12:09:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 2,773 ms
コンパイル使用メモリ 200,320 KB
実行使用メモリ 43,836 KB
最終ジャッジ日時 2023-09-11 07:59:11
合計ジャッジ時間 13,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
42,400 KB
testcase_01 AC 13 ms
42,348 KB
testcase_02 AC 36 ms
42,288 KB
testcase_03 AC 76 ms
42,256 KB
testcase_04 AC 71 ms
42,300 KB
testcase_05 AC 88 ms
42,300 KB
testcase_06 AC 60 ms
42,292 KB
testcase_07 AC 71 ms
42,412 KB
testcase_08 AC 70 ms
42,244 KB
testcase_09 AC 67 ms
42,360 KB
testcase_10 AC 137 ms
42,504 KB
testcase_11 AC 121 ms
42,248 KB
testcase_12 AC 207 ms
42,260 KB
testcase_13 AC 235 ms
42,248 KB
testcase_14 AC 175 ms
42,400 KB
testcase_15 AC 673 ms
43,576 KB
testcase_16 AC 554 ms
43,564 KB
testcase_17 AC 542 ms
43,568 KB
testcase_18 AC 561 ms
43,836 KB
testcase_19 AC 483 ms
43,536 KB
testcase_20 AC 631 ms
43,492 KB
testcase_21 AC 587 ms
43,688 KB
testcase_22 AC 693 ms
43,580 KB
testcase_23 AC 414 ms
43,728 KB
testcase_24 AC 607 ms
43,664 KB
testcase_25 AC 326 ms
43,580 KB
testcase_26 AC 623 ms
43,732 KB
testcase_27 AC 24 ms
42,252 KB
testcase_28 AC 23 ms
42,184 KB
testcase_29 WA -
testcase_30 AC 128 ms
42,744 KB
testcase_31 AC 97 ms
42,740 KB
testcase_32 AC 218 ms
43,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const ll LOG = 18;
ll all[1<<LOG]={};
ll cnt[LOG][1<<LOG]={};

signed main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> as(n);
  for(ll &a:as) cin>>a;

  ll ans=0;
  for(ll i=0;i<LOG;i++){
    if((~x>>i)&1) continue;
    auto f=[&](ll a){return (a>>i)<<i;};

    memset(all,0,sizeof(all));
    for(ll a:as) all[f(a)]++;

    memset(cnt,0,sizeof(cnt));
    for(ll j=0;j<LOG;j++)
      for(ll a:as)
        cnt[j][f(a)]+=(a>>j)&1;

    ll y=(x>>(i+1))<<(i+1);
    for(ll j=0;j<LOG;j++){
      for(ll a:as){
        if((a>>j)&1) ans+=(all[y^f(a)]-(y==0))*(1<<j);
        else ans+=(cnt[j][y^f(a)]-(y==0 and (a>>j)&1))*(1<<j);
      }
    }
  }

  cout<<ans/2<<endl;
  return 0;
}
0