結果

問題 No.206 数の積集合を求めるクエリ
ユーザー tcltk
提出日時 2021-01-15 03:56:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 906 ms / 7,000 ms
コード長 836 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 95,432 KB
最終ジャッジ日時 2024-11-25 00:20:18
合計ジャッジ時間 22,505 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq
import numpy as np

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """4 2 5
# 1 2 3 5
# 1 2
# 5
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    L, M, N = map(int, input().split())
    A = set(list(map(int, input().split())))
    B = set(list(map(int, input().split())))
    Q = int(input())

    f = [1 if i in A else 0 for i in range(N+1)]
    g = [1 if (N-i) in B else 0 for i in range(N+1)]
    fg = np.fft.irfft(np.fft.rfft(f, 2*N+1) * np.fft.rfft(g, 2*N+1), 2*N+1)

    for v in range(Q):
        print(round(fg[N+v]))

if __name__ == '__main__':
    main()
0