#P11099. [ROI 2022] 照明 (Day 1)
[ROI 2022] 照明 (Day 1)
Problem Description
Translated from ROI 2022 D1T4.
On the Cartesian plane, there is a rectangular region whose four corners are at , , , and . There are lamps in this region. The -th lamp is located at .
Each lamp illuminates a -degree angle. The sides of this angle are parallel to the coordinate axes, and its vertex is at the lamp’s position. Therefore, each lamp has four possible illumination directions:

You are given a set of allowed angle directions (the same for all lamps). For each lamp, choose one direction from the allowed set. You need to illuminate as large an area as possible. A point is considered illuminated if it is illuminated by at least one lamp.
Compute the maximum possible illuminated area using the lamps, where each lamp points in one of the allowed directions.
Input Format
Each test point contains multiple test cases.
The first line contains an integer , the number of allowed angle directions in each test case.
The second line contains integers, the indices of the allowed directions (for example, if the light is allowed to shine to the upper-right or lower-left, the input is 1 3). All numbers are distinct and are given in increasing order.
The third line contains an integer , the number of test cases. Then follow test cases.
The first line of each test case contains three integers , representing the number of lamps in the region and the size of the region.
The next lines each contain two integers , representing the coordinates of the -th lamp. It is guaranteed that no two lamps are at the same point.
Output Format
For each test case, output one integer, the maximum possible illuminated area.
1
1
1
4 6 4
3 3
1 2
4 1
5 0
13
2
1 2
1
4 9 7
3 0
0 5
4 4
1 2
55
2
1 3
1
5 6 11
4 2
2 7
1 10
3 8
5 4
57
3
1 2 3
1
5 7 10
1 9
5 5
3 4
2 6
4 3
63
4
1 2 3 4
1
3 8 6
2 2
4 5
6 1
44
Hint
Sample Explanation:
Sample :

Sample :

Sample :

Sample :

Sample :

Constraints:
The full constraints are given in the input format.
| Subtask | Score | Allowed Directions | |
|---|---|---|---|
Translated by ChatGPT 5