結果

問題 No.1958 Bit Game
ユーザー lloyzlloyz
提出日時 2023-10-04 00:02:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 512 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 3,368 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 143,424 KB
最終ジャッジ日時 2023-10-04 00:02:41
合計ジャッジ時間 18,859 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 505 ms
143,260 KB
testcase_01 AC 508 ms
143,296 KB
testcase_02 AC 497 ms
143,164 KB
testcase_03 AC 512 ms
143,332 KB
testcase_04 AC 496 ms
143,176 KB
testcase_05 AC 492 ms
143,216 KB
testcase_06 AC 504 ms
143,360 KB
testcase_07 AC 489 ms
143,320 KB
testcase_08 AC 500 ms
143,424 KB
testcase_09 AC 493 ms
143,048 KB
testcase_10 AC 205 ms
90,112 KB
testcase_11 AC 285 ms
100,800 KB
testcase_12 AC 309 ms
117,244 KB
testcase_13 AC 338 ms
110,184 KB
testcase_14 AC 317 ms
99,248 KB
testcase_15 AC 270 ms
109,556 KB
testcase_16 AC 206 ms
102,452 KB
testcase_17 AC 424 ms
113,068 KB
testcase_18 AC 395 ms
130,924 KB
testcase_19 AC 248 ms
109,196 KB
testcase_20 AC 378 ms
98,716 KB
testcase_21 AC 318 ms
127,768 KB
testcase_22 AC 244 ms
90,256 KB
testcase_23 AC 205 ms
96,536 KB
testcase_24 AC 424 ms
122,540 KB
testcase_25 AC 233 ms
100,604 KB
testcase_26 AC 352 ms
105,964 KB
testcase_27 AC 249 ms
105,660 KB
testcase_28 AC 393 ms
111,836 KB
testcase_29 AC 247 ms
99,388 KB
testcase_30 AC 69 ms
71,084 KB
testcase_31 AC 68 ms
71,224 KB
testcase_32 AC 76 ms
76,276 KB
権限があれば一括ダウンロードができます

ソースコード

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