結果

問題 No.1307 Rotate and Accumulate
ユーザー wolgnikwolgnik
提出日時 2020-12-04 00:47:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 494 ms / 5,000 ms
コード長 452 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 63,712 KB
最終ジャッジ日時 2023-10-12 11:40:56
合計ジャッジ時間 11,484 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
42,448 KB
testcase_01 AC 244 ms
41,888 KB
testcase_02 AC 249 ms
43,404 KB
testcase_03 AC 245 ms
40,740 KB
testcase_04 AC 254 ms
42,992 KB
testcase_05 AC 251 ms
40,688 KB
testcase_06 AC 249 ms
40,604 KB
testcase_07 AC 249 ms
41,608 KB
testcase_08 AC 362 ms
51,532 KB
testcase_09 AC 379 ms
51,456 KB
testcase_10 AC 407 ms
53,596 KB
testcase_11 AC 340 ms
50,184 KB
testcase_12 AC 392 ms
53,652 KB
testcase_13 AC 302 ms
48,144 KB
testcase_14 AC 330 ms
50,272 KB
testcase_15 AC 482 ms
61,916 KB
testcase_16 AC 492 ms
61,360 KB
testcase_17 AC 494 ms
63,712 KB
testcase_18 AC 462 ms
54,872 KB
testcase_19 AC 476 ms
63,128 KB
testcase_20 AC 488 ms
60,512 KB
testcase_21 AC 249 ms
43,984 KB
権限があれば一括ダウンロードができます

ソースコード

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 << 18
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