CF1728G.Illumination

省选/NOI-

通过率:0%

时间限制:8.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider a segment [0,d][0, d] of the coordinate line. There are nn lanterns and mm points of interest in this segment.

For each lantern, you can choose its power — an integer between 00 and dd (inclusive). A lantern with coordinate xx illuminates the point of interest with coordinate yy if ∣x−y∣|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 qq queries. Each query is represented by one integer fif_i. To answer the ii-th query, you have to:

  • add a lantern on coordinate fif_i;
  • calculate the number of valid ways to assign power values to all lanterns, and print it modulo 998244353998244353;
  • remove the lantern you just added.

考虑坐标轴上的一段区间 [0,d][0, d]。该区间内有 nn 个灯笼和 mm 个兴趣点。

对每个灯笼,你可以为其选择一个功率值——一个介于 00 到 dd(含端点)之间的整数。位于坐标 xx 的灯笼能够照亮位于坐标 yy 的兴趣点,当且仅当 ∣x−y∣|x - y| 不超过该灯笼的功率。

若每个兴趣点至少被一个灯笼照亮,则称这种为所有灯笼分配功率值的方式是合法的。

你需要处理 qq 个查询。每个查询由一个整数 fif_i 表示。对于第 ii 个查询,你需要执行以下操作:

  • 在坐标 fif_i 处新增一个灯笼;
  • 计算为当前所有灯笼分配功率值的合法方案总数,并将结果对 998244353998244353 取模后输出;
  • 移除刚刚添加的灯笼。

输入格式

The first line contains three integers dd, nn and mm (4≤d≤3⋅1054 \le d \le 3 \cdot 10^5; 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5; 1≤m≤161 \le m \le 16) — the size of the segment, the number of lanterns and the number of points of interest, respectively.

The second line contains nn integers l1,l2,…,lnl_1, l_2, \dots, l_n (1≤li≤d−11 \le l_i \le d - 1), where lil_i is the coordinate of the ii-th lantern.

The third line contains mm integers p1,p2,…,pmp_1, p_2, \dots, p_m (1≤pi≤d−11 \le p_i \le d - 1), where pip_i is the coordinate of the ii-th point of interest.

The fourth line contains one integer qq (1≤q≤5⋅1051 \le q \le 5 \cdot 10^5) — the number of queries.

The fifth line contains qq integers f1,f2,…,fqf_1, f_2, \dots, f_q (1≤fi≤d−11 \le f_i \le d - 1), where fif_i is the integer representing the ii-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).

第一行包含三个整数 dd、nn 和 mm(4≤d≤3⋅1054 \le d \le 3 \cdot 10^5;1≤n≤2⋅1051 \le n \le 2 \cdot 10^5;1≤m≤161 \le m \le 16),分别表示线段的长度、灯笼的数量以及兴趣点的数量。

第二行包含 nn 个整数 l1,l2,…,lnl_1, l_2, \dots, l_n(1≤li≤d−11 \le l_i \le d - 1),其中 lil_i 表示第 ii 个灯笼的坐标。

第三行包含 mm 个整数 p1,p2,…,pmp_1, p_2, \dots, p_m(1≤pi≤d−11 \le p_i \le d - 1),其中 pip_i 表示第 ii 个兴趣点的坐标。

第四行包含一个整数 qq(1≤q≤5⋅1051 \le q \le 5 \cdot 10^5),表示查询的数量。

第五行包含 qq 个整数 f1,f2,…,fqf_1, f_2, \dots, f_q(1≤fi≤d−11 \le f_i \le d - 1),其中 fif_i 表示第 ii 次查询所对应的整数。

输入的额外约束:在处理每次查询时,任意坐标上至多存在一个物体(即:不存在两个或更多灯笼具有相同坐标,不存在两个或更多兴趣点具有相同坐标,也不存在灯笼与兴趣点位于同一坐标)。

输出格式

For each query, print one integer — the answer to it, taken modulo 998244353998244353.

对于每个查询,输出一个整数——该查询的答案对 998244353998244353 取模的结果。

输入输出样例

  • 输入#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测评打分。不知道怎么写?

首页