結果

問題 No.1142 XOR と XOR
ユーザー tktk_snsntktk_snsn
提出日時 2020-11-29 23:47:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 894 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 37,448 KB
最終ジャッジ日時 2024-11-08 03:50:52
合計ジャッジ時間 21,924 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from collections import Counter
from operator import xor
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7


def make_cnt(A):
    Axor = list(accumulate(A, func=xor, initial=0))
    C = Counter(Axor)
    cnt = [0] * 1024
    for i in range(1024):
        cnt[0] += C[i] * (C[i] - 1) // 2
        for j in range(i + 1, 1024):
            cnt[i ^ j] += C[i] * C[j]
            cnt[i ^ j] %= mod
    return cnt


Acnt = make_cnt(A)
Bcnt = make_cnt(B)
ans = 0
for i in range(1024):
    ans += Acnt[i] * Bcnt[k ^ i]
    ans %= mod
print(ans)
0