結果

問題 No.1307 Rotate and Accumulate
ユーザー 37zigen
提出日時 2020-12-04 13:19:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 989 ms / 5,000 ms
コード長 288 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 94,564 KB
最終ジャッジ日時 2024-09-14 23:20:10
合計ジャッジ時間 18,880 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N,Q=map(int,input().split())
a=list(map(int,input().split()))
r=list(map(int,input().split()))
b=[0]*(2*N+1)
for p in r:
    b[N-p]+=1
fft=np.fft
L=len(a)+len(b)-1
c=fft.irfft(fft.rfft(a,L)*fft.rfft(b,L),L)
B=[0]*N
for i in range(L):
    B[i%N]+=int(c[i]+.5)
print(*B)
0