Editorial for DMOPC '14 Exam Time P6 - Math Homework


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: FatalEagle

Since the source was mentioned in the footer, you can Google HDU 5155 solution for some initial ideas. However, the given solutions are all too slow — O(N3) or O(N4). To speed it up, you can assume each row has at least one 1 ((2C1)R ways to do so) and either use the Inclusion-Exclusion Principle or dynamic programming with the binomial coefficient to compute the ways with R rows and i columns for 1iC.

Time complexity: O(ClogR) or O(C2+ClogR)


Comments

There are no comments at the moment.