Codeforces Round #758 ABCD Solutions (Java/C++)

A. Find Array

Solution:

Obviously, when x>0, x cannot be divisible by x+1. Therefore, we can set a[i]=a[i-1]+1.

Code:

Java

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

C++

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

B. Build the Permutation

Solution:

First, the difference between a and b cannot exceed 1. From the figure below, we can see that to link two "a" (blue), there must be a "b" (red):

The structure is shown in the figure below:

$a \geq b$
a<b

Code:

Java

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

C++

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

C. Game Master

Solution:

First of all, if someone has the greatest strength in a certain picture, then he must be able to win.

And if one person may win, then if another person can defeat this person on a certain picture, then the other person also may win.

So we can use recursion directly.

Code:

Java

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

C++

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

D. Dominoes

The key to this problem is to find that WB and BW can be placed anywhere in most cases.

Codeforces Round #758 Dominoes Solution (Java/C++)
Solution:First of all, we need to notice that after the domino is painted, there are actually only 4 states: BW, WB, WW, BB.
Click the link above for detail solution