結果

問題 No.1618 Convolution?
ユーザー ayaoniayaoni
提出日時 2021-08-08 17:58:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,104 KB
実行使用メモリ 78,684 KB
最終ジャッジ日時 2023-10-19 18:21:41
合計ジャッジ時間 18,892 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 500 ms
42,496 KB
testcase_01 AC 504 ms
42,496 KB
testcase_02 AC 850 ms
72,772 KB
testcase_03 AC 897 ms
75,856 KB
testcase_04 WA -
testcase_05 AC 519 ms
42,496 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
X = np.array([0]+LI())+np.array([0]+LI(),np.int64)
Y = np.array([i for i in range(N+1)],np.int64)


def convolution(A,B):
    size = 1
    while 2*size < len(A)+len(B)-1:
        size *= 2
    size *= 2
    FA = np.fft.rfft(A,size)
    FB = np.fft.rfft(B,size)
    FA *= FB
    Z = np.fft.irfft(FA,size)
    return np.rint(Z).astype(np.int64)


ANS = convolution(X,Y)[1:2*N+1]
print(*ANS)
0