#P7316. [COCI 2018/2019 #3] NLO
[COCI 2018/2019 #3] NLO
Description
You are given an rectangular wheat field. Each cell of the field has some amount of grass. Initially, the amount of grass in every cell is .
Over days, circular UFOs will land on the field and draw circles. On the morning of day , a UFO with radius lands on cell , and all cells within distance from that cell will be affected. If a cell is affected, i.e. , then the amount of grass in that cell becomes . When a new day arrives, the amount of grass in every cell increases by .
Find the sum of grass over all cells on the evening of day .
Input Format
The first line contains positive integers , representing the size of the field.
The second line contains a positive integer , representing the number of days.
The next lines each contain positive integers , describing the landing cell and the radius of the UFO.
Output Format
Output the total amount of grass.
6 6
3
4 4 2
3 3 2
2 4 1
68
100 100
2
50 50 49
30 30 29
9534
33333 44444
1
11111 22222 9999
1167355751
Hint
Explanation of Sample 1
The field on the evening of day 1:
The field on the evening of day 2:
The field on the evening of day 3:
Therefore, the total amount of grass is units.
Constraints
For of the testdata, .
For of the testdata, , , , , .
Note
The score of this problem follows the original COCI settings, with a full score of .
This problem is translated from COCI2018-2019 CONTEST #3 T4 NLO.
Translated by ChatGPT 5
京公网安备 11011102002149号