Educational Codeforces Round 110 ABCDE Solutions (Java/C++)

A. Fair Playoff

Solution:

Just check whether the two winners are the first two largest after sorted or not.

Code:

Java

Submission #118442510 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #118491472 - Codeforces
Codeforces. Programming competitions and contests, programming community

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

Submission #118442525 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #118491718 - Codeforces
Codeforces. Programming competitions and contests, programming community

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.

Educational Codeforces Round 110 Unstable String Solution (Java/C++)
Solution:First, consider if the string is unstable, then how many substrings is beautiful. For 010101, we found it can have 6 substrings which length is 1
Click the link above for more detail solution

D. Playoff Tournament

Similar to segment tree.  Just maintain all the possibilities of the current game and the earlier game.

Educational Codeforces Round 110 Playoff Tournament Solution (Java/C++)
Solution:Like segment tree. Maintain all the possibilities of the current game and the earlier game. For sample data, the Initial state:
Click the link above for more detail solution

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.

Educational Codeforces Round 110 Gold Transfer Solution (C++ only)
Solution:First. Because the cost of child node must higher that their father node. So obviously, we will choose the shallower node. Then we need find the shallowest node which still have gold remained.
Click the link above for more detail solution
DigitalOcean Referral Badge 蜀ICP备19018968号