This page is still under construction.

Parts of this page are still being built. What you see may change.

Gahui and btd5

Time limit2.5sMemory limit512 MB

Summary
A tower at the origin fires M rays; each ray damages every balloon on that direction, and after each shot print how many balloons are still alive.
Level

Medium7 of 10

Topics
Geometry, Hash map, Sorting, Math
Solved
No attempts yet

Problem

btd5 has a Darting Gun Tower. The Darting Gun Tower attacks balloons with the algorithm below.

  • It turns its attack direction toward the target it wants to attack.
  • It lowers the health of the balloons in the attack direction by d.

There is one Darting Gun Tower at coordinates (0, 0).
When the Darting Gun Tower attacks, every balloon placed in the attack direction takes the same amount of damage.
Initially there are N balloons, and the Darting Gun Tower attacked M times. Each time an attack finishes, count the number of remaining balloons.
In the initial state, if the Darting Gun Tower attacks in some direction with damage of at least 10⁹, there is a way to remove all the balloons.

Input

The first line gives N and M.

Lines 2 through N+1 give the x coordinate, y coordinate, and health of each balloon.

Lines N+2 through N+M+1 give the attack direction (x, y) of the Darting Gun Tower and the damage d it deals.

Output

On line x, print the number of balloons remaining after the x-th attack finishes.

Constraints

  • N and M are integers in the range [1, 2×10⁵].
  • The x and y coordinates of the balloons are integers in the range [-10⁹, 10⁹].
  • The positions of the balloons are fixed, and no Darting Gun Tower is at the position of a balloon.
  • No two balloons are at the same position.
  • The hp of the balloons and the damage dealt by the Darting Gun Tower are integers in the range [1, 10⁹].

Examples1

  1. Example 1

    Input
    3 1
    1 1 3
    3 3 4
    2 2 2
    1 1 3
    
    Expected output
    1