#P15945. [JOI Final 2026] 雨落三角 / Triangular Rainfall

[JOI Final 2026] 雨落三角 / Triangular Rainfall

Problem Description

The country of JOI is an equilateral triangle with side length LL whose vertices are points A,BA,B, and CC. Here, LL is a positive integer. Side ABAB connects vertices AA and BB in the east-west direction, and vertex AA is the westernmost point of the country of JOI, while vertex BB is the easternmost point. Vertex CC is the northernmost point of the country of JOI.

The country of JOI is divided into L2L^{2} regions, each of which is an equilateral triangle with side length 11. A point that is a vertex of some region is called a lattice point. For integers x,yx,y satisfying 0yL0 \leq y \leq L and 0xLy0 \leq x \leq L-y, the lattice point that is the (1+y)(1 + y)-st from the south and the (1+x)(1 + x)-st from the west is denoted by (x,y)(x, y). In particular, A,BA,B, and CC are denoted by (0,0),(L,0)(0,0),(L, 0), and (0,L)(0, L), respectively. For example, the following figure shows the regions and the lattice points when L=5L = 5.

::::aligned{center} ::::

In the country of JOI, weather forecasts for the next NN days have been announced. On day ii, rain is forecast to fall in the triangular region TiT_i whose vertices are lattice points (Xi,Yi),(Xi+Zi,Yi)(X_i, Y_i),(X_i + Z_i, Y_i), and (Xi,Yi+Zi)(X_i, Y_i + Z_i). An region is said to be forecast to receive rain on day ii if the entire region is contained in TiT_i.

In order to prepare for disasters caused by rainfall, it is necessary to determine, for each k=1,2,,Kk = 1, 2, \dots, K, the number of regions that are forecast to receive rain on at least kk days.

Given the size of the country of JOI, the weather forecasts, and KK, write a program which, for each k=1,2,,Kk = 1, 2, \dots, K, computes the number of regions that are forecast to receive rain on at least kk days.

Input Format

Input is given from Standard Input in the following format:

LL NN KK
X1X_1 Y1Y_1 Z1Z_1
X2X_2 Y2Y_2 Z2Z_2
\vdots
XNX_N YNY_N ZNZ_N

Output Format

Print KK lines to Standard Output. The kk-th line (1kK1 \leq k \leq K) should contain the number of regions that are forecast to receive rain on at least kk days.

5 2 2
1 0 3
0 1 4
21
4
5 4 5
1 0 4
0 1 3
2 0 2
1 2 2
21
10
2
0
0

Hint

Sample 1

If we illustrate, for each region, the number of days on which rain is forecast to fall, we obtain the following figure.

::::aligned{center} ::::

This sample input satisfies the constraints for Subtasks 11, 22, 33, 44, 88, and 99.

Sample 2

If we illustrate, for each region, the number of days on which rain is forecast to fall, we obtain the following figure. ::::aligned{center} :::: This sample input satisfies the constraints for Subtasks 22, 33, 44, and 99.

Constraints

  • 2L1092 \leq L \leq 10^{9}.
  • 2N2000002 \leq N \leq 200000.
  • 1K51 \leq K \leq 5.
  • 0XiL0 \leq X_i \leq L (1iN1 \leq i \leq N).
  • 0YiL0 \leq Y_i \leq L (1iN1 \leq i \leq N).
  • 1ZiL1 \leq Z_i \leq L (1iN1 \leq i \leq N).
  • Xi+Yi+ZiLX_i + Y_i + Z_i \leq L (1iN1 \leq i \leq N).
  • All input values are integers.

Subtasks

  1. (4 points) N=2N = 2, K=2K = 2.
  2. (5 points) L100L \le 100, N100N \le 100.
  3. (5 points) L1000L \le 1\,000.
  4. (7 points) N2000N \le 2\,000.
  5. (10 points) Xi=0X_i = 0 (1iN)(1 \le i \le N), K=1K = 1.
  6. (10 points) Xi=0X_i = 0 (1iN)(1 \le i \le N).
  7. (23 points) K=1K = 1.
  8. (18 points) K2K \le 2.
  9. (18 points) There are no additional constraints.