結果

問題 No.1240 Or Sum of Xor Pair
ユーザー mkawa2mkawa2
提出日時 2023-11-28 14:42:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,099 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 154,180 KB
最終ジャッジ日時 2023-11-28 14:42:57
合計ジャッジ時間 36,574 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 933 ms
103,288 KB
testcase_01 AC 959 ms
103,304 KB
testcase_02 AC 960 ms
103,304 KB
testcase_03 AC 1,005 ms
145,648 KB
testcase_04 AC 977 ms
140,624 KB
testcase_05 AC 970 ms
131,760 KB
testcase_06 AC 992 ms
132,276 KB
testcase_07 AC 1,002 ms
138,668 KB
testcase_08 AC 1,004 ms
140,876 KB
testcase_09 AC 963 ms
131,348 KB
testcase_10 AC 973 ms
138,716 KB
testcase_11 AC 1,018 ms
149,444 KB
testcase_12 AC 1,011 ms
139,056 KB
testcase_13 AC 1,019 ms
150,388 KB
testcase_14 AC 1,020 ms
150,792 KB
testcase_15 AC 1,070 ms
146,288 KB
testcase_16 AC 1,058 ms
142,652 KB
testcase_17 AC 1,073 ms
149,672 KB
testcase_18 AC 1,081 ms
138,468 KB
testcase_19 AC 1,090 ms
150,256 KB
testcase_20 AC 1,091 ms
153,108 KB
testcase_21 AC 1,078 ms
137,004 KB
testcase_22 AC 1,080 ms
145,972 KB
testcase_23 AC 1,099 ms
151,600 KB
testcase_24 AC 1,058 ms
151,792 KB
testcase_25 AC 1,098 ms
152,376 KB
testcase_26 AC 1,087 ms
143,260 KB
testcase_27 AC 938 ms
103,304 KB
testcase_28 AC 908 ms
105,392 KB
testcase_29 AC 1,042 ms
154,180 KB
testcase_30 AC 988 ms
148,952 KB
testcase_31 AC 999 ms
126,416 KB
testcase_32 AC 1,011 ms
129,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def hadamard(aa):
    k = 1
    while k < len(aa):
        for i in range(len(aa)):
            if i & k: aa[i ^ k], aa[i] = aa[i ^ k]+aa[i], aa[i ^ k]-aa[i]
        k <<= 1

lim=1<<18
n,x=LI()
aa=LI()

cc=[0]*lim
for a in aa:cc[a]+=1
hadamard(cc)
for i in range(lim):cc[i]**=2
hadamard(cc)
for i in range(lim):cc[i]//=lim
ans=(lim-1)*(sum(cc[:x])-n)

base=1
for i in range(18):
    cc = [0]*lim
    cnt=0
    for a in aa:
        if a&base:continue
        cc[a] += 1
        cnt+=1
    hadamard(cc)
    for i in range(lim): cc[i] **= 2
    hadamard(cc)
    for i in range(lim): cc[i] //= lim
    ans -= base*(sum(cc[:x])-cnt)
    base<<=1

print(ans//2)
0