結果

問題 No.1240 Or Sum of Xor Pair
ユーザー 👑 NachiaNachia
提出日時 2020-09-28 17:38:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 166,580 KB
実行使用メモリ 42,392 KB
最終ジャッジ日時 2023-09-15 01:32:07
合計ジャッジ時間 7,755 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
42,212 KB
testcase_01 AC 116 ms
42,312 KB
testcase_02 AC 125 ms
42,256 KB
testcase_03 AC 91 ms
42,268 KB
testcase_04 AC 97 ms
42,232 KB
testcase_05 AC 114 ms
42,204 KB
testcase_06 AC 93 ms
42,256 KB
testcase_07 AC 91 ms
42,252 KB
testcase_08 AC 88 ms
42,320 KB
testcase_09 AC 85 ms
42,312 KB
testcase_10 AC 108 ms
42,236 KB
testcase_11 AC 100 ms
42,384 KB
testcase_12 AC 115 ms
42,204 KB
testcase_13 AC 118 ms
42,312 KB
testcase_14 AC 102 ms
42,188 KB
testcase_15 AC 187 ms
42,192 KB
testcase_16 AC 175 ms
42,208 KB
testcase_17 AC 169 ms
42,276 KB
testcase_18 AC 178 ms
42,392 KB
testcase_19 AC 172 ms
42,252 KB
testcase_20 AC 187 ms
42,388 KB
testcase_21 AC 179 ms
42,264 KB
testcase_22 AC 176 ms
42,292 KB
testcase_23 AC 169 ms
42,384 KB
testcase_24 AC 173 ms
42,212 KB
testcase_25 AC 156 ms
42,228 KB
testcase_26 AC 177 ms
42,252 KB
testcase_27 AC 123 ms
42,236 KB
testcase_28 AC 121 ms
42,200 KB
testcase_29 AC 172 ms
42,256 KB
testcase_30 AC 134 ms
42,204 KB
testcase_31 AC 153 ms
42,236 KB
testcase_32 AC 160 ms
42,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
#define rep(i,n) for(int i=0; i<(n); i++)

LL N, X;
LL C[1<<18][19]={};
LL ans[18]={};

int main(){
	cin>>N>>X;
	rep(i,N){
		int a; cin>>a;
		rep(j,18) if(!(a&(1<<j))) C[a][j]++;
		C[a][18]++;
	}

	rep(d,19){
		int D=1<<d;

		if(X&D){
			int DX=(X-D)&~(D-1);
			for (int i=0; i<1<<18; i+=D) rep(j,18) ans[j] += C[i][18]*C[i^DX][18]-C[i][j]*C[i^DX][j];
		}

		rep(i,1<<18){ if(i&D) rep(j,19) C[i-D][j]+=C[i][j]; }
	}

	LL ansS=0;
	rep(i,18) ansS += ((ans[i]-N+C[0][i])/2)<<i;
	cout<<ansS<<endl;

	return 0;
}
0