結果

問題 No.1503 Bitwise And Convolution Twisted
ユーザー chineristACchineristAC
提出日時 2021-05-07 22:35:52
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,310 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 723,536 KB
最終ジャッジ日時 2023-10-13 13:54:10
合計ジャッジ時間 7,478 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
78,848 KB
testcase_01 AC 98 ms
74,356 KB
testcase_02 AC 98 ms
74,544 KB
testcase_03 AC 98 ms
74,236 KB
testcase_04 AC 99 ms
74,344 KB
testcase_05 AC 95 ms
74,288 KB
testcase_06 AC 146 ms
88,676 KB
testcase_07 AC 802 ms
300,916 KB
testcase_08 AC 179 ms
88,556 KB
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

def subset(n,X):
    res = [[] for i in range(2*n)]
    for i in range(n,2*n):
        res[i] = [X[i-n]]
    for i in range(n-1,-1,-1):
        res[i] = res[2*i] + res[2*i+1]
        size = len(res[i])//2
        for j in range(size):
            res[i][j+size] += res[i][j]
            res[i][j+size] %= mod
    return res[1]

def isubset(n,X):
    res = [[] for i in range(2 * n)]
    for i in range(n,2*n):
        res[i] = [X[i-n]]
    for i in range(n-1,-1,-1):
        res[i] = res[2*i] + res[2*i+1]
        size = len(res[i])//2
        for j in range(size):
            res[i][j+size] -= res[i][j]
            res[i][j+size] %= mod
    return res[1]

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = int(input())
A = li()
B = li()

A = A[::-1]
A1 = subset(1<<N,A)
A1 = A1[::-1]

B1 = isubset(1<<N,B)

C = [A1[k]*B1[k]%mod for k in range(1<<N)]
C = subset(1<<N,C)
print(*C)
"""
C_n = \sum_{i subset n} B_i (\sum_{i subset j subset n} (-1)**(j-i) A1_j)
    = \sum_{i subset n} \sum_{j subset i} A1_i * (i-j) * B_j
    = \sum_{i subset n} A1_i B1_i
"""
0