結果

問題 No.1142 XOR と XOR
ユーザー brthyyjp
提出日時 2022-02-08 13:48:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 114,432 KB
最終ジャッジ日時 2024-11-08 03:59:04
合計ジャッジ時間 4,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mod = 10**9+7

def func(A):
    n = len(A)
    cnt = [0]*(1<<10)
    total = 0
    cnt[0] = 1
    for a in A:
        total ^= a
        cnt[total] += 1
    res = [0]*(1<<10)
    for i in range(1<<10):
        for j in range(i+1, 1<<10):
            res[i^j] += cnt[i]*cnt[j]
    for i in range(1<<10):
        res[i^i] += cnt[i]*(cnt[i]-1)//2
    return res

CA = func(A)
CB = func(B)
ans = 0
for a in range(1<<10):
    for b in range(1<<10):
        if a^b == k:
            ans += CA[a]*CB[b]
            ans %= mod
print(ans)
0