[Solution] Illumination Codeforces Solution | Solution Codeforces
Consider a segment of the coordinate line. There are lanterns and points of interest in this segment.
For each lantern, you can choose its power — an integer between and (inclusive). A lantern with coordinate illuminates the point of interest with coordinate if 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 queries. Each query is represented by one integer . To answer the -th query, you have to:
- add a lantern on coordinate ;
- calculate the number of valid ways to assign power values to all lanterns, and print it modulo ;
- remove the lantern you just added.
The first line contains three integers , and (; ; ) — the size of the segment, the number of lanterns and the number of points of interest, respectively.
The second line contains integers (), where is the coordinate of the -th lantern.
The third line contains integers (), where is the coordinate of the -th point of interest.
The fourth line contains one integer () — the number of queries.
The fifth line contains integers (), where is the integer representing the -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 .
No comments:
Post a Comment