結果

問題 No.1958 Bit Game
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-05-28 04:38:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,789 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 143,208 KB
最終ジャッジ日時 2023-10-20 22:40:04
合計ジャッジ時間 39,325 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,725 ms
143,208 KB
testcase_01 AC 1,789 ms
142,884 KB
testcase_02 AC 1,742 ms
142,884 KB
testcase_03 AC 1,751 ms
142,888 KB
testcase_04 AC 1,715 ms
143,096 KB
testcase_05 AC 1,733 ms
142,884 KB
testcase_06 AC 1,787 ms
143,148 KB
testcase_07 AC 1,692 ms
142,884 KB
testcase_08 AC 1,704 ms
142,884 KB
testcase_09 AC 1,735 ms
142,888 KB
testcase_10 AC 630 ms
89,004 KB
testcase_11 AC 935 ms
106,672 KB
testcase_12 AC 802 ms
111,772 KB
testcase_13 AC 1,208 ms
105,776 KB
testcase_14 AC 1,154 ms
105,172 KB
testcase_15 AC 405 ms
109,756 KB
testcase_16 AC 247 ms
103,752 KB
testcase_17 AC 1,400 ms
113,364 KB
testcase_18 AC 1,121 ms
114,028 KB
testcase_19 AC 444 ms
110,728 KB
testcase_20 AC 1,560 ms
103,344 KB
testcase_21 AC 589 ms
114,164 KB
testcase_22 AC 936 ms
89,108 KB
testcase_23 AC 393 ms
101,584 KB
testcase_24 AC 1,542 ms
119,556 KB
testcase_25 AC 582 ms
104,588 KB
testcase_26 AC 1,391 ms
108,432 KB
testcase_27 AC 323 ms
106,140 KB
testcase_28 AC 1,504 ms
106,784 KB
testcase_29 AC 864 ms
98,852 KB
testcase_30 AC 37 ms
53,424 KB
testcase_31 AC 36 ms
53,424 KB
testcase_32 AC 46 ms
63,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mod = 998244353
cul = lambda s:pow(s,mod-2,mod)
ans = 0
for i in range(18):
    a1,a0,b1,b0 = 0,0,0,0
    for j in range(x):
        if a[j] & (1 << i):a1 += 1
        else:a0 += 1
    for j in range(y):
        if b[j] & (1 << i):b1 += 1
        else:b0 += 1
    dp = [1,0]
    a0x = cul(x) * a0
    a1x = cul(x) * a1
    b0y = cul(y) * b0
    b1y = cul(y) * b1
    for j in range(n):
        n_dp = [0,0]
        n_dp[0] += dp[0] * (a0x + a1x*b0y)
        n_dp[0] += dp[1] * b0y
        n_dp[1] += dp[0] * a1x*b1y
        n_dp[1] += dp[1] * b1y
        n_dp[0] %= mod
        n_dp[1] %= mod
        dp = n_dp
#     print(dp,i)
    ans += pow(x*y,n,mod) * pow(2,i,mod)*dp[1]
    ans %= mod
print(ans)
0