結果
| 問題 |
No.1958 Bit Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-27 22:28:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 373 ms / 2,000 ms |
| コード長 | 714 bytes |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 143,836 KB |
| 最終ジャッジ日時 | 2024-09-20 16:07:16 |
| 合計ジャッジ時間 | 10,098 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
n,x,y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
mod = 998244353
ans = 0
for i in range(18):
nA = [0,0]
nB = [0,0]
for a in A:
if a >> i & 1:
nA[1] += 1
else:
nA[0] += 1
for b in B:
if b >> 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 += (1<<i)*dp[1]%mod
ans %= mod
print(ans)