Experiment "X": Explosions Expected
Time limit1sMemory limit512 MB
Count valid mixtures (at most S total ounces, at least two ingredients used) that are not dominated coordinatewise by any of M given exploding mixtures, modulo nothing.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Intervals, Math
- Solved
- No attempts yet
Problem
Vasya has taken the post of court alchemist, and his task is to brew the philosopher's stone by mixing ingredients.
There are ingredients. An experiment is a plan : Vasya takes ounces of the -th ingredient, pours everything into the crucible, and heats it. Every is a non-negative integer, and the total amount may not exceed the crucible capacity , so . In every experiment at least two ingredients are actually used: at least two of the are strictly positive.
So far every mixture has exploded. Vasya has spotted a monotonicity rule: if a plan explodes, then every plan with for all explodes as well.
Vasya has already carried out experiments, and all of them exploded. Call a plan definitely unsuccessful when the monotonicity rule guarantees it will explode, i.e. when at least one of the exploded plans satisfies for every .
Count how many valid experiment plans are not definitely unsuccessful. A plan is valid when every is a non-negative integer, , and at least two of the are positive.
Input
The first line contains three integers , , and (, , ), where is the number of experiments already conducted. Each of the next lines contains integers describing one already-conducted experiment (all of which exploded).
Output
Print one integer: the number of valid experiment plans that are not definitely unsuccessful. This count can be very large, so print the exact value.