A. XOR
So bit bit computing consideration.
Every $ 0 / $ 1 in the value of the number of digits $ dp $ statistics, just take a ride on the result.
B. Take stones
$ O (n ^ 4) $ $ a $ be apparent DP.
$ Dp $ can be found in the state of losing is very small.
So a direct hit list
It is possible to use brush losing status table $ dp $, is the complexity.
C. Optimization
It is a very important property:
When the maximum value will be $ abs $ apart, the answer does not make worse.
Therefore, the contribution of each step of the selected state in advance added,
They are considered single-step contributions to the negative and positive contribution,
It can be taken directly transferred $ $ max.