結果
| 問題 |
No.1503 Bitwise And Convolution Twisted
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-05-07 23:31:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,105 ms / 2,000 ms |
| コード長 | 979 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 359,104 KB |
| 最終ジャッジ日時 | 2024-09-15 11:37:27 |
| 合計ジャッジ時間 | 7,068 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
def zeta_to_high(res,n):
for i in range(n):
i = 1<<i
for j in range(1<<n):
if j&i: res[j] += res[j^i]
def zeta_to_low(res,n):
for i in range(n):
i = 1<<i
for j in range(1<<n):
if j&i == 0: res[j] += res[j^i]
def mobius_to_low(res,n):
for i in range(n):
i = 1<<i
for j in range(1<<n):
if j&i == 0: res[j] -= res[j^i]
def mobius_to_high(res,n):
for i in range(n):
i = 1<<i
for j in range(1<<n):
if j&i: res[j] -= res[j^i]
MOD = 998244353
n = int(input())
*a, = map(int,input().split())
*b, = map(int,input().split())
popcount = [1]*(1<<n)
for i in range(n):
for j in range(1<<i):
popcount[j+(1<<i)] = -popcount[j]
for i in range(1<<n):
if popcount[i]==-1: b[i] *= -1
zeta_to_low(a,n)
zeta_to_high(b,n)
for i in range(1<<n):
a[i] = (a[i]%MOD)*(b[i]%MOD)%MOD
mobius_to_high(a,n)
print(*[ai*popcount[i]%MOD for i,ai in enumerate(a)])
convexineq