結果

問題 No.1958 Bit Game
ユーザー mkawa2mkawa2
提出日時 2022-05-27 22:23:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 1,309 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 140,812 KB
最終ジャッジ日時 2023-10-20 20:26:39
合計ジャッジ時間 7,826 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 261 ms
140,548 KB
testcase_01 AC 253 ms
140,544 KB
testcase_02 AC 264 ms
140,548 KB
testcase_03 AC 259 ms
140,544 KB
testcase_04 AC 258 ms
140,468 KB
testcase_05 AC 255 ms
140,548 KB
testcase_06 AC 260 ms
140,812 KB
testcase_07 AC 262 ms
140,548 KB
testcase_08 AC 256 ms
140,548 KB
testcase_09 AC 267 ms
140,548 KB
testcase_10 AC 103 ms
87,968 KB
testcase_11 AC 149 ms
104,352 KB
testcase_12 AC 170 ms
112,200 KB
testcase_13 AC 173 ms
105,140 KB
testcase_14 AC 157 ms
102,536 KB
testcase_15 AC 167 ms
108,316 KB
testcase_16 AC 130 ms
101,776 KB
testcase_17 AC 221 ms
111,312 KB
testcase_18 AC 198 ms
112,504 KB
testcase_19 AC 148 ms
108,612 KB
testcase_20 AC 181 ms
101,576 KB
testcase_21 AC 169 ms
112,580 KB
testcase_22 AC 118 ms
88,224 KB
testcase_23 AC 115 ms
100,324 KB
testcase_24 AC 213 ms
119,488 KB
testcase_25 AC 126 ms
103,236 KB
testcase_26 AC 173 ms
106,116 KB
testcase_27 AC 149 ms
104,852 KB
testcase_28 AC 196 ms
106,484 KB
testcase_29 AC 126 ms
97,524 KB
testcase_30 AC 37 ms
53,352 KB
testcase_31 AC 35 ms
53,352 KB
testcase_32 AC 43 ms
59,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def cal(k):
    dp = [1, 0]
    for _ in range(n):
        ndp = [0, 0]
        ndp[0] = dp[0]*(x*y%md-cc[0][k]*cc[1][k]%md)%md+dp[1]*x%md*(y-cc[1][k])%md
        ndp[1] = dp[0]*cc[0][k]%md*cc[1][k]%md+dp[1]*x%md*cc[1][k]%md
        ndp[0] %= md
        ndp[1] %= md
        dp = ndp

    return dp[1]*pow(2, k, md)%md

def cnt(aa, i):
    for a in aa:
        for k in range(18):
            cc[i][k] += a & 1
            a >>= 1

n, x, y = LI()
aa = LI()
bb = LI()

cc = [[0]*18, [0]*18]
cnt(aa, 0)
cnt(bb, 1)

ans = 0
for k in range(18):
    ans += cal(k)
    ans %= md

print(ans)
0