結果

問題 No.206 数の積集合を求めるクエリ
ユーザー maspy
提出日時 2020-03-06 13:24:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 647 ms / 7,000 ms
コード長 587 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 65,424 KB
最終ジャッジ日時 2024-10-14 02:46:07
合計ジャッジ時間 21,210 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


# %%
L, M, N = map(int, readline().split())
A = np.array(readline().split(), np.int64)
B = np.array(readline().split(), np.int64)
Q = int(read())


# %%
f = np.zeros(N + 1, np.int64)
g = np.zeros(N + 1, np.int64)
f[A] += 1
g[N - B] += 1


# %%
fft = np.fft.rfft
ifft = np.fft.irfft
fft_len = 1 << 18
fg = np.rint(ifft(fft(f, fft_len) * fft(g, fft_len), fft_len)).astype(np.int64)
print('\n'.join(fg[N:N + Q].astype(str)))
0