Umbral Decoding
Time limit2sMemory limit512 MB
Given up to 100 safe points (x, y, b), count lattice points (p, q) in the square [0, n]^2 that are not covered by any region |x-p|^3 + |y-q|^3 <= b.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
You are planning an attack on a new encryption algorithm. To succeed you must find the key, which is a pair of integers . Think of the key as a point on the two dimensional integer lattice whose position is unknown. For a given you do know that lies in the square spanned by the lattice points and , that is, .
The attack has three stages.
- Identify the safe points and their bounds.
- Eliminate from the key candidates every point that lies in the umbra of some safe point.
- Test the remaining points to see which one is the key.
Stage 1 is already done, and several safe points of the form are given as input.
In stage 2 you eliminate a point when it lies in the umbra of some safe point. Point is in the umbra of safe point if and only if
Count how many points are left for stage 3, so that the amount of work still needed to finish the attack is known.

Figure 1. Safe points and their umbra (red) and the remaining points (blue), for one example.
Input
The first line holds two integers and separated by a space, with and .
Each of the next lines holds three integers , , separated by spaces, describing one safe point. Both and are in the range , and the bound is also in the range .
Output
Print the number of points with that do not lie in the umbra of any safe point.