Curved into the array A.
Prefixes and demand of each line,
Enumeration about the endpoint, O (n) sweep down, by the way update barrel.
Maintain the content of the stack empty the bucket.
B. General's Command
k = 1, chubby defend the palace a weaker version.
And chubby keep the palace, it is found special properties:
Point of no weight.
Consider greedy.
Find the deepest depth of each point, it lights up the k-class father.
1. k stage lighting lighting any of its father better than a son, because it can more coverage to the node outside of the subtree.
2. The lighting points outside the subtree level k father, can not cover the depth of the deepest point.
In summary, the greedy strategy is correct.
I thought of this greedy strategy exams,
However, by limiting chubby defend the palace, stubbornly believe that greed is not necessarily true.
That question has been done in the past for a long time, have forgotten points of difference.
In fact, you can try greedy, to make a shot.
C. stars
Flip a great range of modification, refractory.
Consider how to modify the range is a single point.
The difference can be.
$ A_i provided that the initial state of $ $ $ I lamp 1 is off and 0 is on.
Provided $ b_i = a_i ^ a_ {i + 1} $, b is a value apparently prefix and represents a single point.
The modification interval $ (l, r) $ conversion modified $ l-1 $ and $ $ R & lt single point, the two inverted values reached interval modification effect.
The final state is required for the full number of columns b 0.
The two inverted 1 0 is meaningless.
The move is meaningful to continue with a 1 0 negated until the two co-invert 1 to 0.
bfs paths between some process 1, no more than between the 2k 1-like pressure.
Complexity is $ O (2 ^ {2k} * k ^ 2 + nmk) $
However dp transfer some redundancy.
Fixing a transfer order to achieve optimal results.
Each transfer 1 first, complexity $ O (2 ^ {2k} * k + nmk) $.