結果

問題 No.1240 Or Sum of Xor Pair
ユーザー chocoruskchocorusk
提出日時 2020-09-25 21:54:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 128,884 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2023-09-10 15:23:01
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
11,236 KB
testcase_01 AC 29 ms
11,496 KB
testcase_02 AC 29 ms
11,336 KB
testcase_03 AC 31 ms
11,196 KB
testcase_04 AC 31 ms
11,320 KB
testcase_05 AC 30 ms
11,228 KB
testcase_06 AC 30 ms
11,188 KB
testcase_07 AC 29 ms
11,236 KB
testcase_08 AC 30 ms
11,188 KB
testcase_09 AC 31 ms
11,188 KB
testcase_10 AC 37 ms
11,332 KB
testcase_11 AC 38 ms
11,268 KB
testcase_12 AC 43 ms
11,288 KB
testcase_13 AC 41 ms
11,180 KB
testcase_14 AC 43 ms
11,188 KB
testcase_15 AC 95 ms
11,264 KB
testcase_16 AC 98 ms
11,272 KB
testcase_17 AC 97 ms
11,248 KB
testcase_18 AC 98 ms
11,332 KB
testcase_19 AC 95 ms
11,188 KB
testcase_20 AC 96 ms
11,232 KB
testcase_21 AC 98 ms
11,236 KB
testcase_22 AC 96 ms
11,236 KB
testcase_23 AC 90 ms
11,268 KB
testcase_24 AC 93 ms
11,188 KB
testcase_25 AC 97 ms
11,184 KB
testcase_26 AC 93 ms
11,188 KB
testcase_27 AC 30 ms
11,240 KB
testcase_28 AC 30 ms
11,188 KB
testcase_29 WA -
testcase_30 AC 50 ms
11,360 KB
testcase_31 AC 57 ms
11,188 KB
testcase_32 AC 82 ms
11,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
void FWT(vector<ll> &v){
	int m=v.size();
	for(int i=1; i<m; i<<=1){
		for(int j=0; j<m; j++){
			if((i&j)==0){
				ll x=v[j], y=v[j^i];
				v[j]=x+y, v[j^i]=x-y;
			}
		}
	}
}
int main()
{
	int n, x; cin>>n>>x;
	if(x==0){
		cout<<0<<endl;
		return 0;
	}
	vector<ll> v(1<<18), vx(1<<18);
	ll ans=0;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		v[a]++;
		vx[a]+=a;
		ans-=a;
	}
	FWT(v); FWT(vx);
	vector<ll> w(1<<18), wx(1<<18);
	for(int i=0; i<(1<<18); i++) w[i]=v[i]*v[i], wx[i]=vx[i]*v[i];
	FWT(w); FWT(wx);
	for(int i=0; i<(1<<18); i++) w[i]>>=18, wx[i]>>=18;
	for(int i=0; i<x; i++){
		ans+=w[i]*i/2+wx[i];
	}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}
0