結果

問題 No.1503 Bitwise And Convolution Twisted
ユーザー convexineqconvexineq
提出日時 2021-05-07 23:31:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,320 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 338,136 KB
最終ジャッジ日時 2023-10-13 14:52:06
合計ジャッジ時間 8,793 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,336 KB
testcase_01 AC 61 ms
71,304 KB
testcase_02 AC 60 ms
71,056 KB
testcase_03 AC 61 ms
71,244 KB
testcase_04 AC 63 ms
71,328 KB
testcase_05 AC 62 ms
71,280 KB
testcase_06 AC 94 ms
78,848 KB
testcase_07 AC 321 ms
172,228 KB
testcase_08 AC 163 ms
78,908 KB
testcase_09 AC 1,078 ms
335,944 KB
testcase_10 AC 1,320 ms
338,136 KB
testcase_11 AC 951 ms
338,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)])
0