#P15940. [JOI Final 2026] 花园 3 / Garden 3
[JOI Final 2026] 花园 3 / Garden 3
Problem Description
The JOI-Garden has a rectangular shape divided into a grid of rows and columns. The cell in the -th row from the top and the -th column from the left is called cell .
When rain falls on a cell, the moisture level of that cell increases. The moisture level of a cell never changes except when it rains. If the moisture level of a cell becomes at least , the cell turns into mud, which is dangerous. Therefore, every morning, JOI-kun, the manager of the JOI-Garden, may designate at most one rectangular off-limits area that contains all cells whose moisture level is at least . More precisely, JOI-kun chooses four integers (, ), and the rectangular region consisting of all cells satisfying and becomes off-limits.
Initially, the moisture level of every cell in the JOI Garden is .
Starting today, it will rain once every evening for days. On the evening of the -th day after (), rain falls on every cell satisfying and , and the moisture level of each such cell increases by .
For each , write a program that computes the minimum possible number of cells contained in the off-limits area that JOI-kun sets on the morning of the -th day after.
Input Format
Read the following data from the standard input.
Output Format
Write lines to the standard output. The -th line () of the output should contain the minimum possible number of cells contained in the off-limits area that JOI-kun sets on the morning of day .
3 3 5 10
3 3 1 1 5
1 3 1 2 7
1 3 3 3 4
1 1 1 2 12
3 3 3 3 6
0
1
1
6
9
9 1 5 1
3 3 1 1 4
5 8 1 1 1
3 5 1 1 3
8 8 1 1 4
8 9 1 1 5
1
6
6
6
7
4596 9794 15 141929907
600 3070 2222 8763 472026497
47 2644 3276 6033 930213777
638 945 304 1100 992702990
370 2211 2178 2977 783902937
277 2601 1559 8989 842013671
566 3272 3124 8456 254633541
91 4241 2655 8035 303526265
1342 3662 3909 7175 685435928
1176 4012 2827 8429 614977118
255 2461 1482 5835 794902067
982 2314 941 3952 342731056
1603 2215 6730 7105 332440107
2301 4568 6898 9561 591652619
124 2097 3520 8882 168525684
1845 3599 5592 7145 555656973
16165282
19783008
25583040
25583040
26266464
28021036
36437770
36437770
36437770
36437770
36437770
36437770
41864676
41864676
41864676
Hint
Sample 1
The following is one example of how the moisture levels increase each day and how the off-limits area can be chosen so that the number of contained cells is minimized.
- On the evening of day , the moisture level of cell increases by . On the morning of day , there are no cells whose moisture level of at least , so no off-limits area is set.
- On the evening of day , the moisture level of cells , , , , , and each increase by . On the morning of day , cell has moisture level of at least . JOI-kun chooses and , thereby setting a off-limits area that contains cell.
- On the evening of day , the moisture level of cells , , and each increase by . On the morning of day , cell has moisture level of at least . JOI-kun chooses and , thereby setting a off-limits area that contains cell.
- On the evening of day , the moisture level of cells , and each increase by . On the morning of day , cells ,, and has moisture level of at least . JOI-kun chooses , , , , thereby setting a off-limits area that contains cells.
- On the evening of day , the moisture level of cell increases by . On the morning of day , cells , , , and has moisture level of at least . JOI-kun chooses , , , , thereby setting a off-limits area that contains cells.
This sample input satisfies the constraints of Subtasks , and .
Sample 2
This sample input satisfies the constraints of all the subtasks.
Sample 3
This sample input satisfies the constraints of Subtasks , and .
Constraints
- .
- .
- .
- .
- ().
- ().
- ().
- Given values are all integers.
Subtasks
- ( points) .
- ( points) .
- ( points) .
- ( points) .
- ( points) No additional constraints.