Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author: Riolku
Subtask 1
Just output any strictly increasing array.
Subtask 2
Just output any strictly increasing grid. A simple one would be to set position ~(i, j)~ to ~i + j~, assuming ~i~ and ~j~ are one-indexed.
Subtask 3
It is optimal to greedily choose the smallest value for each cell, sweeping left to right. For instance, for:
$$\displaystyle (0, 3, 0, 6)$$
We greedily place a ~1~ in the first slot and a ~4~ in the third, to get:
$$\displaystyle (1, 3, 4, 6)$$
Subtask 4
Apply the same strategy as subtask ~3~, except that we have to consider the cell below and to the left this time. A greedy approach still works.
Comments