結果

問題 No.1240 Or Sum of Xor Pair
ユーザー chineristACchineristAC
提出日時 2020-08-22 19:52:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 86,440 KB
実行使用メモリ 144,752 KB
最終ジャッジ日時 2023-09-04 07:44:14
合計ジャッジ時間 25,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 289 ms
137,952 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 282 ms
137,896 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random,time

N,X=map(int,input().split())
A=list(map(int,input().split()))

def solve_not_convolute():
    data=[0 for i in range(2**18)]
    for i in range(N):
        data[A[i]]+=1
    cum=[data[i] for i in range(2**18)]
    cum_s=[[data[i]*(i>>j &1) for j in range(18)] for i in range(2**18)]
    for i in range(1,2**18):
        for j in range(18):
            cum_s[i][j]+=cum_s[i-1][j]
        cum[i]+=cum[i-1]

    def cnt_s(r,x):
        id=x
        res=[0 for i in range(18)]
        cnt=0
        for i in range(18,-1,-1):
            if r>>i &1:
                L=(id>>i)<<i
                R=L+(1<<i)-1
                cnt+=cum[R]-cum[L-1]*(L>0)
                for j in range(18):
                    res[j]+=cum_s[R][j]-cum_s[L-1][j]*(L>0)
                id^=(1<<i)
        S=0
        for i in range(18):
            if x>>i &1:
                S+=(1<<i)*(cnt-res[i])
            else:
                S+=(1<<i)*res[i]
        return S

    res=0
    for i in range(N):
        res+=cnt_s(X,A[i])
    res//=2
    return res

print(solve_not_convolute())
0