Editorial for The Contest Contest 1 P5 - A Typical CCO Problem
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
In this subtask, no overlaps are allowed so the optimal arrangement maximizes the number of  houses. There are two cases:
- Case 1: 
is even
The optimal arrangement is to placehouses that cover columns
and cover the remaining squares with
houses. For each
house, its top left corner could be in either row
or
. Hence, the minimum number of houses required is
and there are
possible arrangements. To optimize our computations, we can use binary exponentiation.
 - Case 2: 
is odd
This case is similar to case 1, except that the optimal arrangement always has exactly one column that consists ofhouses. Since we can insert this column between any of the
houses, there are
possible placements. Hence, the minimum number of houses required is
and there are
possible arrangements.
 
Subtask 2
Since there is only  square that allows overlaps, the only way to utilize it is for two 
 houses to share a corner square. Thus, this square must be in the interior. We also observe that an optimal arrangement only uses the overlap when 
 is odd. If these conditions are met, the minimum number of houses required is 
 and there are 
 possible arrangements.
Subtask 3 and 4
The intended solution is to use dynamic programming. One possible state is to store the minimum number of houses required and the number of arrangements that uses this number of houses for the first  columns, separating them by the types of houses used in the 
 column. To transition to the 
 column, we check if column 
 or 
 contain any squares allowing overlaps and account for them accordingly.
Subtask 3 was meant to reward partial points for erroneous solutions.
Time Complexity:Subtask 5
Instead of computing DP states for each column, we only need to compute them for columns containing a square that allows overlaps or columns that are adjacent to such squares. Then we can use our idea from subtask 1 to quickly compute the gap in between. Careful implementation is required to avoid over/undercounting.
Time Complexity:
Comments