CF1728G.Illumination
省选/NOI-
通过率:0%
时间限制:8.00s
内存限制:512MB
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.
考虑坐标轴上的一段区间 [0,d]。该区间内有 n 个灯笼和 m 个兴趣点。
对每个灯笼,你可以为其选择一个功率值——一个介于 0 到 d(含端点)之间的整数。位于坐标 x 的灯笼能够照亮位于坐标 y 的兴趣点,当且仅当 ∣x−y∣ 不超过该灯笼的功率。
若每个兴趣点至少被一个灯笼照亮,则称这种为所有灯笼分配功率值的方式是合法的。
你需要处理 q 个查询。每个查询由一个整数 fi 表示。对于第 i 个查询,你需要执行以下操作:
- 在坐标 fi 处新增一个灯笼;
- 计算为当前所有灯笼分配功率值的合法方案总数,并将结果对 998244353 取模后输出;
- 移除刚刚添加的灯笼。
输入格式
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).
第一行包含三个整数 d、n 和 m(4≤d≤3⋅105;1≤n≤2⋅105;1≤m≤16),分别表示线段的长度、灯笼的数量以及兴趣点的数量。
第二行包含 n 个整数 l1,l2,…,ln(1≤li≤d−1),其中 li 表示第 i 个灯笼的坐标。
第三行包含 m 个整数 p1,p2,…,pm(1≤pi≤d−1),其中 pi 表示第 i 个兴趣点的坐标。
第四行包含一个整数 q(1≤q≤5⋅105),表示查询的数量。
第五行包含 q 个整数 f1,f2,…,fq(1≤fi≤d−1),其中 fi 表示第 i 次查询所对应的整数。
输入的额外约束:在处理每次查询时,任意坐标上至多存在一个物体(即:不存在两个或更多灯笼具有相同坐标,不存在两个或更多兴趣点具有相同坐标,也不存在灯笼与兴趣点位于同一坐标)。
输出格式
For each query, print one integer — the answer to it, taken modulo 998244353.
对于每个查询,输出一个整数——该查询的答案对 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
输入解题思路,AI测评打分。不知道怎么写?