A. Fair Playoff
Solution:
Just check whether the two winners are the first two largest after sorted or not.
Code:
Java
C++
B. Array Reodering
Solution:
Obviously, it is greedy. Put all the even numbers in the front. Because only the numbers in the back have chance to multiply by 2. So, after sorted by this way, then just calculate GCD in brute force.
Code:
Java
C++
C. Unstable String
There only two mode: 0101... and 1010... Use this way to find the longest unstable substring. And then just remove the repeat part made by the question marks.
D. Playoff Tournament
Similar to segment tree. Just maintain all the possibilities of the current game and the earlier game.
E. Gold Transfer
Just binary search. But because this is a interactive problem, and Java IO is too hard, so only have C++ AC code here.