The setup sounds like BFS/simulation at first and I think most people go down that path before realizing it's a counting problem.
Model the infection process as a combinatorial problem where each day's spread corresponds to choosing a direction for each infected segment. Use dynamic programming or combinatorial counting to compute the number of distinct orderings, considering the initial infected positions and the constraints of 1D spread.
Pro tip: Clarify that 'distinct orderings' refers to the sequence of infection events (which house gets infected when), not the final configuration. This shows attention to detail and avoids misinterpretation.
Confirm that we are counting the number of possible sequences of infection events (orderings) that lead to all houses infected, given the initial infected set. Ensure understanding of 'distinct orderings' and constraints.
Split the array into independent segments separated by initially infected houses. Each segment is a contiguous block of uninfected houses bounded by infected houses or array ends.
For each segment, the infection spreads from the boundaries inward. The number of orderings is the number of ways to interleave the infections from the left and right boundaries, which is a binomial coefficient based on segment length and distances to boundaries.
Multiply the counts for each segment and then multiply by the multinomial coefficient to account for interleaving infections across different segments, since segments are independent.
Consider cases where there are no initially infected houses (impossible to infect all), or where all houses are initially infected (only one ordering). Also handle segments at the ends with only one boundary.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.