結果

問題 No.1958 Bit Game
ユーザー lloyz
提出日時 2023-10-04 00:02:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 142,340 KB
最終ジャッジ日時 2024-07-26 14:14:23
合計ジャッジ時間 13,308 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, x, y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 998244353
Pow2 = [pow(2, i, mod) for i in range(18)]

ans = 0
for i in range(18):
    nA = [0, 0]
    nB = [0, 0]
    for j in range(x):
        if (A[j] >> i) & 1:
            nA[1] += 1
        else:
            nA[0] += 1
    for j in range(y):
        if (B[j] >> i) & 1:
            nB[1] += 1
        else:
            nB[0] += 1
    DP = [1, 0]
    for j in range(n):
        NDP = [0, 0]
        NDP[0] = DP[0] * nA[0] % mod
        NDP[1] = (DP[0] * nA[1] + DP[1] * x) % mod
        DP = NDP[:]
        NDP = [0, 0]
        NDP[0] = (DP[0] * y + DP[1] * nB[0]) % mod
        NDP[1] = DP[1] * nB[1] % mod
        DP = NDP[:]
    ans += Pow2[i] * DP[1] % mod
    ans %= mod
print(ans)
0