結果

問題 No.1307 Rotate and Accumulate
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-21 09:37:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 721 ms / 5,000 ms
コード長 421 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 93,696 KB
最終ジャッジ日時 2024-05-01 18:31:55
合計ジャッジ時間 15,325 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 446 ms
43,848 KB
testcase_01 AC 447 ms
43,968 KB
testcase_02 AC 458 ms
43,840 KB
testcase_03 AC 450 ms
43,976 KB
testcase_04 AC 444 ms
44,220 KB
testcase_05 AC 460 ms
43,968 KB
testcase_06 AC 455 ms
44,228 KB
testcase_07 AC 466 ms
43,840 KB
testcase_08 AC 567 ms
66,344 KB
testcase_09 AC 598 ms
67,664 KB
testcase_10 AC 580 ms
70,216 KB
testcase_11 AC 552 ms
65,092 KB
testcase_12 AC 609 ms
69,952 KB
testcase_13 AC 496 ms
48,928 KB
testcase_14 AC 517 ms
55,812 KB
testcase_15 AC 721 ms
92,960 KB
testcase_16 AC 693 ms
93,368 KB
testcase_17 AC 691 ms
93,684 KB
testcase_18 AC 684 ms
86,052 KB
testcase_19 AC 711 ms
93,480 KB
testcase_20 AC 696 ms
93,696 KB
testcase_21 AC 465 ms
44,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
R = list(map(int, input().split()))

cnt = [0] * N
for r in R:
    cnt[r - 1] += 1
cnt *= 2
cnt.reverse()

sz = len(A) + len(cnt) - 1
fft_len = 1 << (sz - 1).bit_length()
ca = np.fft.rfft(A, fft_len)
cc = np.fft.rfft(cnt, fft_len)
X = np.fft.irfft(ca * cc, fft_len)[:sz]
X = (X.real + 0.1).astype(np.int64)

print(*X[N:N+N].tolist())
0