結果

問題 No.1240 Or Sum of Xor Pair
ユーザー msm1993msm1993
提出日時 2020-10-06 11:51:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 165,904 KB
実行使用メモリ 42,504 KB
最終ジャッジ日時 2023-09-27 06:31:25
合計ジャッジ時間 9,324 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
42,228 KB
testcase_01 AC 123 ms
42,216 KB
testcase_02 AC 128 ms
42,272 KB
testcase_03 AC 92 ms
42,248 KB
testcase_04 AC 102 ms
42,276 KB
testcase_05 AC 118 ms
42,280 KB
testcase_06 AC 96 ms
42,224 KB
testcase_07 AC 94 ms
42,232 KB
testcase_08 AC 93 ms
42,380 KB
testcase_09 AC 89 ms
42,492 KB
testcase_10 AC 113 ms
42,268 KB
testcase_11 AC 106 ms
42,496 KB
testcase_12 AC 123 ms
42,288 KB
testcase_13 AC 131 ms
42,260 KB
testcase_14 AC 113 ms
42,232 KB
testcase_15 AC 197 ms
42,340 KB
testcase_16 AC 187 ms
42,268 KB
testcase_17 AC 178 ms
42,504 KB
testcase_18 AC 183 ms
42,336 KB
testcase_19 AC 176 ms
42,280 KB
testcase_20 AC 200 ms
42,356 KB
testcase_21 AC 190 ms
42,228 KB
testcase_22 AC 185 ms
42,228 KB
testcase_23 AC 171 ms
42,204 KB
testcase_24 AC 185 ms
42,228 KB
testcase_25 AC 167 ms
42,216 KB
testcase_26 AC 192 ms
42,228 KB
testcase_27 AC 130 ms
42,260 KB
testcase_28 AC 129 ms
42,356 KB
testcase_29 AC 178 ms
42,408 KB
testcase_30 AC 145 ms
42,268 KB
testcase_31 AC 163 ms
42,232 KB
testcase_32 AC 173 ms
42,280 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