A. 辣鸡 (ljh)
simulation.
For answers within the same block, direct statistics.
For the different blocks,
I is greater than i and enumeration of $ j = i + 1 ~ n $,
An effective pruning:
$ $ X_1 to sort a first dimension, when the $ x_ {1j}> x_ {2i} + 1 $ break exits the loop.
However, if longitudinal or linear data into the card is $ O (n ^ 2) $, but the question has not card.
A better approach is sorted by each different conditions, binary search truly effective range and statistical answer.
The total number of hydrogen bonds associated with interval N linear (at least not a special data structure I), can be guaranteed and the complexity of sorting bipartite $ O (nlogn) $.
However, I tune out.
B. template (ac)
C. Gangster (kat)
The most simple of a question, but the examination room only think of the practice of k = 2, playing the n <= 8 search violence.
The idea was:
First question is only effective on the first day, the last question valid for only one day last,
However, the intermediate title days will total effective k, k obviously can not process each questions, and finally by $ (n-k + 1) $ ah.
But the fact is defeated:
Consider the number of programs, regardless of which one in the program number of each state are the same.
Processing each k questions,
Enumeration biggest difficulty i, k is the most difficult days i,
Then i have a choice every day, to get rid of illegal state, that is the biggest difficulty is not i,
The simple inclusion and exclusion, the answer is $ i ^ k- (i-1) ^ k $.
Finally, by dividing the m ^ k, by $ (n-k + 1) $ can.