P8496 NOI2022 众数
Solution 1 (Ad-Hoc)
If a number of the absolute mode, then it will dominate every binary position. We can maintain the max occurrence for every digit in the binary representation.
Solution 2
We can have a segment tree binary search idea. The mode of the entire segment is at least the mode of 1 side. We can do this kind of binary search all the way down. When we have multiple sequences, we can do this for every one of all the segments trees left / right side. We can still guarantee half-split so this is correct. INITIAL BINARY SEARCH LOGIC LEFT TO BE VERIFIED, THE MODES NEED QUERYING THE OTHER SIDE, THIS MAY NOT WORK
There is another method with a segment tree: We can use a segment tree on the value range, then we're querying for the median. This can also be done with binary search on segment tree.
Some Small Implementation Details
We need a link list for the 1/2 ops.