QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#6183. 赛场监控问题

الإحصائيات

一场编程比赛的赛场被划分成 $r$ 行 $c$ 列的方格,每个机位都位于一个方格中。赛场内的监控探头位于赛场中方格分割线的共 $(r + 1) \times (cc + 1)$ 个交点处。水平分割线自上而下编号为 $0$ 到 $r$;垂直分割线自左向右编号为 $0$ 到 $c$。每个监控探头所处位置可以用其分割线坐标表示为一个二元组 $(x, y)$。监控探头的朝向有“右上”、“左上”、“左下”、“右下”共 $4$ 个方向,依照其象限的顺序编号为 $1$ 到 $4$。相应监控探头朝向能监控的范围如下图所示。

$$\begin{matrix}2&1\\3&4\end{matrix}$$

由于受到线路与信号的条件限制,监控探头的朝向只能从一个特定集合 $S$ 中选择,其中 $S \subseteq \{ 1, 2,3, 4 \}$。

赛场监控问题:对于给定的赛场划分,和赛场内的监控探头的位置 $(x_i, y_i)$,以及监控探头可选择的朝向集合 $S$,计算在此环境中,监控探头可以监控到的最多机位数。

输入格式

输入文件依次给出待计算的多个测试数据。

第一行有一个正整数 $k$,表示给定的监控探头朝向集合 $S$ 的大小。

第二行按照从小到大次序给出集合 $S$ 中的元素。

第三行有一个正整数 $t$,表示共有 $t$ 组测试数据。

对于每组测试数据:

第一行有三个正整数 $n, r,c$,分别表示赛场内有 $n$ 个监控探头,赛场被划分成 $r$ 行 $c$ 列的方格阵列。

接下来的 $n$ 行中,第 $i$ 行包含两个正整数 $x_i, y_i$,表示赛场内的监控探头位置为 $(x_i, y_i)$。

输出格式

对于每组测试数据,依次输出在相应环境中,监控探头可以监控到的最多机位数。每行输出一个正整数。

样例数据

样例输入

4
1 2 3 4
1
3 6 8
4 2
1 4
5 6

样例输出

44

子任务

测试数据中 $100\%$ 的数据满足,$n \leq 10^5 ,0 \leq x_i ≤ r ≤ 10^9, 0 \leq y_i \leq c \leq 10^9$。

测试数据中 $100\%$ 的数据满足,$\sum n \leq 10^5$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.