結果
問題 | No.1240 Or Sum of Xor Pair |
ユーザー | vwxyz |
提出日時 | 2023-12-16 05:22:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,642 ms / 2,000 ms |
コード長 | 1,819 bytes |
コンパイル時間 | 604 ms |
コンパイル使用メモリ | 82,400 KB |
実行使用メモリ | 259,608 KB |
最終ジャッジ日時 | 2024-09-27 07:24:46 |
合計ジャッジ時間 | 49,639 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,170 ms
245,488 KB |
testcase_01 | AC | 1,196 ms
245,836 KB |
testcase_02 | AC | 1,199 ms
245,980 KB |
testcase_03 | AC | 1,345 ms
249,784 KB |
testcase_04 | AC | 1,342 ms
249,668 KB |
testcase_05 | AC | 1,383 ms
250,508 KB |
testcase_06 | AC | 1,368 ms
249,340 KB |
testcase_07 | AC | 1,334 ms
250,268 KB |
testcase_08 | AC | 1,351 ms
249,208 KB |
testcase_09 | AC | 1,366 ms
249,900 KB |
testcase_10 | AC | 1,367 ms
254,324 KB |
testcase_11 | AC | 1,383 ms
254,980 KB |
testcase_12 | AC | 1,371 ms
254,312 KB |
testcase_13 | AC | 1,390 ms
254,876 KB |
testcase_14 | AC | 1,393 ms
254,132 KB |
testcase_15 | AC | 1,485 ms
259,112 KB |
testcase_16 | AC | 1,511 ms
259,452 KB |
testcase_17 | AC | 1,516 ms
259,472 KB |
testcase_18 | AC | 1,505 ms
259,236 KB |
testcase_19 | AC | 1,519 ms
259,344 KB |
testcase_20 | AC | 1,542 ms
259,512 KB |
testcase_21 | AC | 1,481 ms
259,608 KB |
testcase_22 | AC | 1,520 ms
259,472 KB |
testcase_23 | AC | 1,536 ms
259,368 KB |
testcase_24 | AC | 1,642 ms
259,240 KB |
testcase_25 | AC | 1,549 ms
259,268 KB |
testcase_26 | AC | 1,555 ms
259,208 KB |
testcase_27 | AC | 1,237 ms
246,440 KB |
testcase_28 | AC | 1,219 ms
247,152 KB |
testcase_29 | AC | 1,472 ms
259,336 KB |
testcase_30 | AC | 1,389 ms
258,428 KB |
testcase_31 | AC | 1,343 ms
258,344 KB |
testcase_32 | AC | 1,398 ms
259,244 KB |
ソースコード
import sys readline=sys.stdin.readline def Hadamard(polynomial,n,mod=0,inverse=False): polynomial_=[x for x in polynomial]+[0]*((1<<n)-len(polynomial)) for bit in range(n): for i in range(1<<n): ii=i^(1<<bit) if i>ii: continue polynomial_[i],polynomial_[ii]=polynomial_[i]+polynomial_[ii],polynomial_[i]-polynomial_[ii] if mod: polynomial_[i]%=mod polynomial_[ii]%=mod if inverse: if mod: inve_2=pow((mod+1)//2,n) for i in range(1<<n): polynomial_[i]*=inve_2 polynomial_[i]%=mod else: pow_2=pow(2,n) for i in range(1<<n): polynomial_[i]//=pow_2 return polynomial_ def XOR_Convolution(polynomial0,polynomial1,mod=0): n=(max(len(polynomial0),len(polynomial1))-1).bit_length() Hadamard_polynomial0=Hadamard(polynomial0,n,mod=mod) Hadamard_polynomial1=Hadamard(polynomial1,n,mod=mod) if mod: convolution=[x*y%mod for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] else: convolution=[x*y for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] convolution=Hadamard(convolution,n,mod=mod,inverse=True) return convolution N,X=map(int,readline().split()) A=list(map(int,readline().split())) M=18 ans=0 C=[[0]*(1<<M) for m in range(M+1)] for a in A: C[M][a]+=1 for m in range(M): if a&1<<m: C[m][a]+=1 for m in range(M+1): C[m]=Hadamard(C[m],M) for bit in range(1<<M): C[m][bit]**=2 C[m]=Hadamard(C[m],M,inverse=True) for x in range(X): for m in range(M): if x&1<<m: ans+=C[M][x]<<m else: ans+=C[m][x]<<m for a in A: ans-=a ans//=2 print(ans)