CF1728G.Illumination
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider a segment [0,d] of the coordinate line. There are n lanterns and m points of interest in this segment.
For each lantern, you can choose its power — an integer between 0 and d (inclusive). A lantern with coordinate x illuminates the point of interest with coordinate y if ∣x−y∣ is less than or equal to the power of the lantern.
A way to choose the power values for all lanterns is considered valid if every point of interest is illuminated by at least one lantern.
You have to process q queries. Each query is represented by one integer fi . To answer the i -th query, you have to:
- add a lantern on coordinate fi ;
- calculate the number of valid ways to assign power values to all lanterns, and print it modulo 998244353 ;
- remove the lantern you just added.
输入格式
The first line contains three integers d , n and m ( 4≤d≤3⋅105 ; 1≤n≤2⋅105 ; 1≤m≤16 ) — the size of the segment, the number of lanterns and the number of points of interest, respectively.
The second line contains n integers l1,l2,…,ln ( 1≤li≤d−1 ), where li is the coordinate of the i -th lantern.
The third line contains m integers p1,p2,…,pm ( 1≤pi≤d−1 ), where pi is the coordinate of the i -th point of interest.
The fourth line contains one integer q ( 1≤q≤5⋅105 ) — the number of queries.
The fifth line contains q integers f1,f2,…,fq ( 1≤fi≤d−1 ), where fi is the integer representing the i -th query.
Additional constraint on the input: during the processing of each query, no coordinate contains more than one object (i. e. there cannot be two or more lanterns with the same coordinate, two or more points of interest with the same coordinate, or a lantern and a point of interest with the same coordinate).
输出格式
For each query, print one integer — the answer to it, taken modulo 998244353 .
输入输出样例
输入#1
6 1 1 4 3 3 2 1 5
输出#1
48 47 47
输入#2
6 1 2 4 2 5 2 1 3
输出#2
44 46
输入#3
20 1 2 11 15 7 1 8
输出#3
413
输入#4
20 3 5 5 7 18 1 6 3 10 19 5 4 17 15 8 9
输出#4
190431 187503 188085 189903 189708