QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100

#15739. 奇怪的天线

Estadísticas

总统想要普查他的国家。该国的领土是一个由 $n \times n$ 个网格单元组成的网格。 网格中每个单元的每个角定义了一个点(行和列的索引均从 $0$ 到 $n$,且 $0 < n \le 30000$)。总统可以在网格的任意一个点上安装天线。

这种天线会向四个方向之一发射信号:东南(SE)、西南(SW)、东北(NE)、西北(NW)。信号的形状是一个等腰直角三角形。该三角形的两条等长直角边表示天线的功率($0 < p \le 2n$)。该三角形定义了天线在网格中的覆盖范围。

总统已经安装了一些天线(我们称这个数量为 $a$,$0 \le a \le 100$),并希望确定被覆盖的网格单元总数。

但这些天线很奇特,因为在任何一个单元中,如果来自两个天线的信号重叠,它们就会互相抵消。换句话说,对于任意给定的单元,当且仅当有奇数个信号在该单元中重叠时,该单元才会被覆盖。

例如,给定一个 $10 \times 10$ 的网格,点的范围从 $0$ 到 $10$:

x x x x - - - - - -
x o o y y - - - - -
x x y y y - - - - -
x - - y y - - - - -
- - - - y - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -

在图中,天线 $x$ 位于第 $0$ 行、第 $0$ 列,向东南方向发射功率为 $4$ 的信号。天线 $y$ 位于第 $1$ 行、第 $5$ 列,向西南方向发射功率为 $4$ 的信号。在上述情况下,总共有 $16$ 个单元被覆盖。

输入格式

输入数据的格式如下: 第一行包含网格单元数 $n$。 第二行包含天线数 $a$。 接下来的 $a$ 行,每行对应一个天线,包含:line_positioncolumn_positionpowerorientation,它们之间用空格分隔。 方向(orientation)是一个在 $0$ 到 $3$ 范围内的整数(0: SW, 1: SE, 2: NE, 3: NW)。

输出格式

输出应为被天线覆盖的网格单元数量。

样例

输入样例 1

10
2
0 0 4 1
1 5 4 0

输出样例 1

16

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.