Editorial for VMSS '15 #0 - Head Data Slave Applications
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
,Despite being the first (or 0th) problem, this is one of the more difficult ones in the contest. The militants must be arranged such that the last militant with label must be placed before . This can be reworded to having militants with labels must be after .
Now, let's assume we have spots where is the sum of all militants. The spot must be filled by a militant with the label . The order of the rest of the militants labeled (all of them) do not matter.
Now those familiar with combinatorics will recognize how we can choose to organize all militants however we want, this bringing in the classical question " choose ". We can repeat this backwards with each group of militants starting with .
To do this, we can build a Pascal's triangle and query the answer in time.
Final complexity:
Comments