Editorial for The Hu Tao Fractal
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
,Subtask 1
It is sufficient to check if the 3x3 grid is a Hu-Tao Fractal by checking each of the numbers in the grid.Time Complexity: O()
Subtask 2 & 3
We can utilize a recursive approach to solve the remaining subtask.Let be the greatest number so that is a power of 3, and . We check each 3x3 grid in the grid for one of 3 states, which we store in a new grid.
1. If the 3x3 grid is a Hu-Tao Fractal, we store the grid as 1.
2. If the 3x3 grid is COMPLETELY EMPTY, we store the grid as 0.
3. Otherwise, we store the grid as 2.
We then check this new grid in a similar fashion.
We continue checking the grid until we cannot find a Hu-Tao Fractal in the grid. Let be the number of times we simplified the grid. The largest Hu-Tao Fractal identifiable in this grid will be . We then take the maximum of for all grids.
Time Complexity: O()
Comments