結果

問題 No.206 数の積集合を求めるクエリ
ユーザー tcltktcltk
提出日時 2021-01-15 03:56:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 533 ms / 7,000 ms
コード長 836 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 84,540 KB
最終ジャッジ日時 2023-08-16 11:54:31
合計ジャッジ時間 13,148 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,908 KB
testcase_01 AC 135 ms
29,896 KB
testcase_02 AC 134 ms
29,964 KB
testcase_03 AC 133 ms
30,288 KB
testcase_04 AC 134 ms
29,968 KB
testcase_05 AC 136 ms
29,896 KB
testcase_06 AC 137 ms
30,772 KB
testcase_07 AC 139 ms
30,884 KB
testcase_08 AC 136 ms
30,600 KB
testcase_09 AC 138 ms
31,028 KB
testcase_10 AC 136 ms
29,920 KB
testcase_11 AC 136 ms
30,096 KB
testcase_12 AC 146 ms
30,948 KB
testcase_13 AC 147 ms
30,852 KB
testcase_14 AC 148 ms
30,564 KB
testcase_15 AC 145 ms
30,912 KB
testcase_16 AC 143 ms
30,916 KB
testcase_17 AC 344 ms
61,452 KB
testcase_18 AC 343 ms
83,400 KB
testcase_19 AC 308 ms
59,824 KB
testcase_20 AC 275 ms
53,988 KB
testcase_21 AC 287 ms
52,736 KB
testcase_22 AC 286 ms
54,668 KB
testcase_23 AC 315 ms
59,956 KB
testcase_24 AC 517 ms
61,324 KB
testcase_25 AC 512 ms
61,348 KB
testcase_26 AC 483 ms
53,576 KB
testcase_27 AC 418 ms
51,796 KB
testcase_28 AC 533 ms
84,540 KB
testcase_29 AC 485 ms
53,336 KB
testcase_30 AC 484 ms
52,472 KB
権限があれば一括ダウンロードができます

ソースコード

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