結果

問題 No.1307 Rotate and Accumulate
ユーザー wolgnik
提出日時 2020-12-04 00:47:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 451 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 65,508 KB
最終ジャッジ日時 2024-09-14 10:32:14
合計ジャッジ時間 14,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 RE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))
r = list(map(int, input().split()))
ln = 1 << 4
A = np.zeros(ln)
B = np.zeros(ln)
for i in range(N): A[N - i - 1] = a[i]
for q in r: B[q] += 1
C = np.fft.rfft(A) * np.fft.rfft(B)
c = np.fft.irfft(C)
res = [0] * N
for i in range(len(c)): res[i % N] += c[i]
res.reverse()
res = [int(res[i] + 0.5) for i in range(N)]
print(*res)
0