結果

問題 No.1142 XOR と XOR
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-11 10:24:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,267 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 136,844 KB
最終ジャッジ日時 2023-10-18 09:45:21
合計ジャッジ時間 4,966 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
73,500 KB
testcase_01 AC 80 ms
73,508 KB
testcase_02 AC 79 ms
73,516 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 153 ms
118,232 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 161 ms
131,560 KB
testcase_11 AC 78 ms
73,516 KB
testcase_12 AC 78 ms
73,512 KB
testcase_13 AC 77 ms
73,524 KB
testcase_14 WA -
testcase_15 AC 121 ms
98,136 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 148 ms
121,204 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List


MOD = int(1e9) + 7
INV = pow(2, MOD - 2, MOD)


def xorConvolution(a: List[int], b: List[int]) -> List[int]:
    a, b = a[:], b[:]
    a = _walshHadamardTransform(a, 1)
    b = _walshHadamardTransform(b, 1)
    for i in range(len(a)):
        a[i] = a[i] * b[i] % MOD
    res = _walshHadamardTransform(a, INV)
    return res


def _walshHadamardTransform(f, op):
    n = len(f)
    l_, k = 2, 1
    while l_ <= n:
        for i in range(0, n, l_):
            for j in range(k):
                f[i + j], f[i + j + k] = (f[i + j] + f[i + j + k]) * op % MOD, (
                    f[i + j] + MOD - f[i + j + k]
                ) * op % MOD
        l_, k = l_ << 1, k << 1
    return f


if __name__ == "__main__":
    n, m, k = map(int, input().split())
    nums1 = list(map(int, input().split()))
    nums2 = list(map(int, input().split()))

    MAX = 1024
    f, g = [0] * MAX, [0] * MAX
    f[0], g[0] = 1, 1
    xor_ = 0
    for num in nums1:
        xor_ ^= num
        f[xor_] += 1
    xor_ = 0
    for num in nums2:
        xor_ ^= num
        g[xor_] += 1

    f, g = xorConvolution(f, f), xorConvolution(g, g)
    f[0], g[0] = (f[0] - n - 1) % MOD, (g[0] - m - 1) % MOD

    res = xorConvolution(f, g)
    print((res[k] // 4) % MOD)
0