結果

問題 No.1240 Or Sum of Xor Pair
ユーザー chineristACchineristAC
提出日時 2020-08-23 12:00:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 88,184 KB
最終ジャッジ日時 2023-09-04 07:47:14
合計ジャッジ時間 5,929 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import random

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

def solve_tri():
    data_c=[[0 for j in range(64)] for i in range(4096)]
    data_bit=[[0 for j in range(6)] for i in range(4096)]
    cnt=[0 for i in range(4096)]
    for i in range(N):
        x,y=A[i]>>6,A[i]%64
        data_c[x][y]+=1
        cnt[x]+=1
        for j in range(6):
            if y>>j &1:
                data_bit[x][j]+=1

    def all_sum(x,y):
        res=0
        upper_const=(x^y)<<6
        res+=upper_const*cnt[x]*cnt[y]
        for i in range(6):
            res+=(1<<i)*(data_bit[x][i]*(cnt[y]-data_bit[y][i])+(cnt[x]-data_bit[x][i])*data_bit[y][i])
        return res

    def convolute(x,y):
        res=0
        upper_const=(x^y)<<6
        tmp=[0 for i in range(X%64)]
        for i in range(64):
            for j in range(64):
                if i^j<X%64:
                    tmp[i^j]+=data_c[x][i]*data_c[y][j]
        for i in range(len(tmp)):
            res+=(upper_const+i)*tmp[i]
        return res

    ans=0
    for i in range(4096):
        for j in range(4096):
            if i^j<(X>>6):
                ans+=all_sum(i,j)
            elif i^j==(X>>6):
                ans+=convolute(i,j)
    ans//=2
    return ans

print(solve_tri())
0