結果

問題 No.206 数の積集合を求めるクエリ
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-27 20:49:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 250 ms / 7,000 ms
コード長 524 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 50,500 KB
最終ジャッジ日時 2023-09-20 21:04:24
合計ジャッジ時間 8,776 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,508 KB
testcase_01 AC 134 ms
29,684 KB
testcase_02 AC 134 ms
29,536 KB
testcase_03 AC 136 ms
29,588 KB
testcase_04 AC 138 ms
29,512 KB
testcase_05 AC 137 ms
29,420 KB
testcase_06 AC 137 ms
29,992 KB
testcase_07 AC 135 ms
29,968 KB
testcase_08 AC 137 ms
29,992 KB
testcase_09 AC 137 ms
30,096 KB
testcase_10 AC 134 ms
29,472 KB
testcase_11 AC 134 ms
29,668 KB
testcase_12 AC 137 ms
30,324 KB
testcase_13 AC 139 ms
30,144 KB
testcase_14 AC 138 ms
29,944 KB
testcase_15 AC 135 ms
30,112 KB
testcase_16 AC 136 ms
29,976 KB
testcase_17 AC 205 ms
50,376 KB
testcase_18 AC 183 ms
49,952 KB
testcase_19 AC 205 ms
49,016 KB
testcase_20 AC 186 ms
49,756 KB
testcase_21 AC 190 ms
49,560 KB
testcase_22 AC 193 ms
50,492 KB
testcase_23 AC 204 ms
50,500 KB
testcase_24 AC 250 ms
50,196 KB
testcase_25 AC 246 ms
50,420 KB
testcase_26 AC 229 ms
49,212 KB
testcase_27 AC 213 ms
49,480 KB
testcase_28 AC 235 ms
49,160 KB
testcase_29 AC 234 ms
49,996 KB
testcase_30 AC 227 ms
49,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
fft = np.fft.rfft
ifft = np.fft.irfft

L, M, N = map(int, input().split())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
Q = int(input())

Fa = np.zeros(N+1, dtype=np.int32)
Fb = np.zeros(N+1, dtype=np.int32)
Fa[A] = 1
Fb[B] = 1

sz = len(Fa) + len(Fb) - 1
fft_len = 1 << (sz - 1).bit_length()
Ca = fft(Fa[::-1], fft_len)
Cb = fft(Fb, fft_len)
F = ifft(Ca * Cb, fft_len)
F = np.rint(F).astype(np.int32)
ans = F[N-Q+1:N+1].tolist()
print(*ans[::-1], sep="\n")
0