QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 512 MB Total points: 50

#17540. Zombie Apocalypse

Statistics

Vito 沉迷于一款热门新游戏《僵尸启示录》(Zombie Apocalypse)。他目前正面临以下挑战:$m$ 只僵尸正朝城市走去,如果他不阻止它们,它们就会袭击城市。

具体来说,僵尸位于距离城市 $n$ 米的一个秘密洞穴中,并逐个离开洞穴。僵尸以每秒 $1$ 米的速度向城市走去,相邻两只僵尸离开洞穴的时间间隔为 $1$ 秒。

因此,在第 $1$ 秒结束时,有一只僵尸距离洞穴 $1$ 米;在第 $2$ 秒结束时,有两只僵尸分别距离洞穴 $1$ 米和 $2$ 米;在第 $3$ 秒结束时,有三只僵尸分别距离洞穴 $1$ 米、$2$ 米和 $3$ 米,依此类推。当僵尸通过第 $n$ 米时,它就到达了城市。

根据游戏规则,Vito 可以在洞穴和城市之间的路径上投下 $k$ 枚炸弹以阻止袭击。对于每枚炸弹,他已经选好了:

  • 投下炸弹的位置(距离洞穴的距离),
  • 炸弹的爆炸半径,以及
  • 投下炸弹的时间(以秒为单位)。

在时间 $t$、位置 $x$ 投下的半径为 $r$ 的炸弹,会摧毁在时间 $t$ 位于位置 $y$ 且满足 $|x - y| \le r$ 的僵尸。已经到达城市的僵尸不会受到炸弹的影响。一旦僵尸被摧毁,它就不能再继续前往城市。

Vito 可以选择在任何位置、半径和时间投下炸弹,多枚炸弹可以同时发生,甚至可以在同一位置。

给定 Vito 对这 $k$ 枚炸弹的选择,请确定有多少只僵尸会到达城市。

输入格式

第一行包含三个自然数 $n$、$m$ 和 $k$($1 \le n, m, k \le 200$),分别表示洞穴与城市之间的路径长度、僵尸数量和炸弹数量。

接下来的 $k$ 行中,每行包含三个自然数 $x$、$r$ 和 $t$($1 \le x \le n$,$0 \le r \le n$,$1 \le t \le 500$),分别表示投下某枚炸弹时距离洞穴的距离(米)、该炸弹的半径(米)以及投下该炸弹的时间(秒)。

输出格式

第一行也是唯一的一行,输出一个整数,表示成功到达城市的僵尸数量。

子任务

子任务 分值 数据范围
1 13 $m = 1$
2 27 $k = 1$
4 30 无附加限制

样例

输入样例 1

6 3 3
3 1 2
5 0 7
4 4 8

输出样例 1

1

输入样例 2

7 7 1
3 2 6

输出样例 2

2

输入样例 3

3 3 1
3 3 3

输出样例 3

0

样例 1 说明

time: 0, cave: {z, z, z}, path: (0, 0, 0, 0, 0, 0), city: {}
time: 1, cave: {z, z}, path: (z, 0, 0, 0, 0, 0), city: {}
time: 2, cave: {z}, path: (z, z, 0, 0, 0, 0), city: {}
time: 2, cave: {z}, path: (z, z, 0, 0, 0, 0), city: {}
time: 2, cave: {z}, path: (z, 0, 0, 0, 0, 0), city: {}
time: 3, cave: {}, path: (z, z, 0, 0, 0, 0), city: {}
time: 4, cave: {}, path: (0, z, z, 0, 0, 0), city: {}
time: 5, cave: {}, path: (0, 0, z, z, 0, 0), city: {}
time: 6, cave: {}, path: (0, 0, 0, z, z, 0), city: {}
time: 7, cave: {}, path: (0, 0, 0, 0, z, z), city: {}
time: 7, cave: {}, path: (0, 0, 0, 0, z, z), city: {}
time: 7, cave: {}, path: (0, 0, 0, 0, 0, z), city: {}
time: 8, cave: {}, path: (0, 0, 0, 0, 0, 0), city: {z}
time: 8, cave: {}, path: (0, 0, 0, 0, 0, 0), city: {z}
time: 8, cave: {}, path: (0, 0, 0, 0, 0, 0), city: {z}

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.