#P15350. [COCI 2025/2026 #4] 僵尸启示录 / Zombie Apocalypse

    ID: 17314 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>模拟COCI(克罗地亚)2026

[COCI 2025/2026 #4] 僵尸启示录 / Zombie Apocalypse

Problem Description

There are mm zombies that are going to attack the city.

The zombies set off one by one from a zombie nest that is (n+1)(n+1) meters away from the city. Each zombie moves at a speed of 11 meter per second, towards the city. The time interval between consecutive zombies leaving the nest is 11 second. Let the time when the first zombie departs be the beginning of the 11-st second.

This means:

  • At the end of the 11-st second, there is a zombie 11 meter away from the nest.
  • At the end of the 22-nd second, there are zombies 1,21,2 meters away from the nest.
  • At the end of the 33-rd second, there are zombies 1,2,31,2,3 meters away from the nest.
  • And so on.

When a zombie is (n+1)(n+1) meters away from the nest, it arrives at the city.

Now we place kk bombs on the road to defend the city. For each bomb, we know the following information:

  • The bomb's position (i.e., its distance from the nest).
  • The bomb's explosion radius.
  • The time when the bomb is installed.

For a bomb with radius rr, suppose it is installed at position xx at time tt. This bomb will kill a zombie located at position yy if and only if ∣x−y∣≤r|x-y|\le r holds at time tt. Zombies that have already arrived in the city will not be killed. A killed zombie cannot continue moving.

Bombs may be installed at any time and position; in particular, there may be multiple bombs at the same time (and/or) at the same position.

Find the number of zombies that arrive in the city.

Input Format

The first line contains three positive integers n,m,kn,m,k (1≤n,m,k≤2001\le n,m,k\le 200).

The next kk lines each contain three integers x,r,tx,r,t (1≤x≤n1\le x\le n,0≤r≤n0\le r\le n,1≤t≤5001\le t\le 500), describing a bomb, where:

  • The bomb is installed xx meters away from the nest.
  • The explosion radius is rr meters.
  • The installation time is at the end of the tt-th second.

Output Format

Output one line with one integer: the number of zombies that arrive in the city.

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

Hint

Sample Explanation

The explanation for sample 1 is shown in the table below.

Time (end of the ii-th second) In the nest On the road to the city In the city
Initial state {z,z,z}\{z, z, z\} (0,0,0,0,0,0)(0, 0, 0, 0, 0, 0) {}\{\}
11 {z,z}\{z, z\} (z,0,0,0,0,0)(z, 0, 0, 0, 0, 0)
22 {z}\{z\} (z,z,0,0,0,0)(z, z, 0, 0, 0, 0)
(z,z,0,0‾,0,0)(z, \underline{z, \mathbf{0}, 0}, 0, 0)
(z,0,0,0,0,0)(z, 0, 0, 0, 0, 0)
33 {}\{\} (z,z,0,0,0,0)(z, z, 0, 0, 0, 0)
44 (0,z,z,0,0,0)(0, z, z, 0, 0, 0)
55 (0,0,z,z,0,0)(0, 0, z, z, 0, 0)
66 (0,0,0,z,z,0)(0, 0, 0, z, z, 0)
77 (0,0,0,0,z,z)(0, 0, 0, 0, z, z)
(0,0,0,0,z‾,z)(0, 0, 0, 0, \underline{\bf z}, z)
(0,0,0,0,0,z)(0, 0, 0, 0, 0, z)
88 (0,0,0,0,0,0)(0, 0, 0, 0, 0, 0) {z}\{z\}
(0,0,0,0,0,0‾)(\underline{0, 0, 0, \mathbf{0}, 0, 0})
(0,0,0,0,0,0)(0, 0, 0, 0, 0, 0)

Subtasks

Subtask ID Score Constraints
11 13 13 m=1m=1
22 27 27 k=1k=1
33 30 30 No additional constraints.

Translated by ChatGPT 5