Communication Stations
Time limit1.5sMemory limit1024 MB
Count the lattice points in an N by M map that lie within Manhattan distance p_i of at least one of K stations.
- Level
Medium6 of 10
- Topics
- Prefix sum, Geometry, Implementation
- Solved
- No attempts yet
Problem
The Republic of Korea Air Force installed communication stations at several locations so that it could communicate smoothly with fighter jets in flight and with ground units. So far, stations have been placed. Station sits at and emits a signal with strength . Any fighter jet at an integer lattice point that satisfies can communicate with that station. When signals from different stations overlap, each keeps its original strength.
Given the map height , the map width , and the positions and strengths of the stations, count the integer lattice points inside the map where a fighter jet can communicate with at least one station.
Input
The first line contains three integers , , and , separated by spaces. (, )
From line 2 to line , each line contains three integers , , and , separated by spaces, which are the row position, column position, and signal strength of station . (, , )
No two stations share the same position.
Output
Print the number of integer lattice points inside the map where a fighter jet can communicate with at least one station.