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 — \mathcal{O}(N^3) or \mathcal{O}(N^4). To speed it up, you can assume each row has at least one 1 ((2^C-1)^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 1 \le i \le C.

Time complexity: \mathcal{O}(C \log R) or \mathcal{O}(C^2 + C \log R)


There are no comments at the moment.