## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Illumination Codeforces Solution | Solution Codeforces

G. Illumination
time limit per test
8 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Consider a segment $\left[0,d\right]$ 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 ${f}_{i}$. To answer the $i$-th query, you have to:

• add a lantern on coordinate ${f}_{i}$;
• calculate the number of valid ways to assign power values to all lanterns, and print it modulo $998244353$;
• remove the lantern you just added.
Input

The first line contains three integers $d$$n$ and $m$ ($4\le d\le 3\cdot {10}^{5}$$1\le n\le 2\cdot {10}^{5}$$1\le m\le 18$) — the size of the segment, the number of lanterns and the number of points of interest, respectively.

The second line contains $n$ integers ${l}_{1},{l}_{2},\dots ,{l}_{n}$ ($1\le {l}_{i}\le d-1$), where ${l}_{i}$ is the coordinate of the $i$-th lantern.

Solution Click Below:-  👉
👇👇👇👇👇

The third line contains $m$ integers ${p}_{1},{p}_{2},\dots ,{p}_{m}$ ($1\le {p}_{i}\le d-1$), where ${p}_{i}$ is the coordinate of the $i$-th point of interest.

The fourth line contains one integer $q$ ($1\le q\le 5\cdot {10}^{5}$) — the number of queries.

The fifth line contains $q$ integers ${f}_{1},{f}_{2},\dots ,{f}_{q}$ ($1\le {f}_{i}\le d-1$), where ${f}_{i}$ 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).

Output

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