結果

問題 No.206 数の積集合を求めるクエリ
ユーザー shotoyooshotoyoo
提出日時 2020-09-23 22:55:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 297 ms / 7,000 ms
コード長 963 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 58,392 KB
最終ジャッジ日時 2023-09-10 13:10:26
合計ジャッジ時間 8,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,756 KB
testcase_01 AC 132 ms
29,676 KB
testcase_02 AC 132 ms
29,672 KB
testcase_03 AC 132 ms
29,760 KB
testcase_04 AC 133 ms
29,620 KB
testcase_05 AC 131 ms
29,736 KB
testcase_06 AC 133 ms
30,276 KB
testcase_07 AC 135 ms
30,440 KB
testcase_08 AC 133 ms
30,368 KB
testcase_09 AC 134 ms
30,200 KB
testcase_10 AC 132 ms
29,648 KB
testcase_11 AC 133 ms
29,812 KB
testcase_12 AC 136 ms
30,604 KB
testcase_13 AC 137 ms
30,392 KB
testcase_14 AC 138 ms
30,512 KB
testcase_15 AC 135 ms
30,416 KB
testcase_16 AC 133 ms
30,368 KB
testcase_17 AC 297 ms
53,868 KB
testcase_18 AC 218 ms
48,296 KB
testcase_19 AC 260 ms
52,500 KB
testcase_20 AC 224 ms
48,044 KB
testcase_21 AC 235 ms
48,640 KB
testcase_22 AC 233 ms
49,788 KB
testcase_23 AC 260 ms
51,980 KB
testcase_24 AC 293 ms
58,392 KB
testcase_25 AC 284 ms
57,516 KB
testcase_26 AC 247 ms
55,392 KB
testcase_27 AC 229 ms
50,616 KB
testcase_28 AC 253 ms
56,168 KB
testcase_29 AC 257 ms
55,604 KB
testcase_30 AC 242 ms
54,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


l,m,n = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
q = int(input())
a = [0]*n
b = [0]*n
for i in range(l):
    a[aa[i]-1] = 1
for i in range(m):
    b[bb[i]-1] = 1
b = b[::-1]
# FFT
import numpy as np
M = 998244353
a = np.array(a, dtype=np.int64)
b = np.array(b, dtype=np.int64)
def fft(a,b):
    l = 1
    while 2 * l < len(a) + len(b) - 1:
        l *= 2
    l *= 2
    c = np.fft.irfft((np.fft.rfft(a,l))*(np.fft.rfft(b,l)),l)
    c = np.rint(c).astype(np.int64)
    return c
def fft_large(a,b):
    d = 30000
    a1, a2 = np.divmod(a,d)
    b1, b2 = np.divmod(b,d)
    aa = fft(a1,b1)
    bb = fft(a2,b2)
    cc = (fft(a1+a2, b1+b2) - (aa+bb))
    h = (((aa*d))*d  + cc*d + bb)
    return h
c = fft(a,b)
write("\n".join(map(str, c[n-1:n-1+q].tolist())))
0