Codeforces Round #724 ABCDE Solutions (Java/C++)

A. Omkar and Bad Story

Solution:

Obviously, if there is any number in the array is less than zero. Then by using this number as the subtracted number, the array can grow indefinitely.

But if there is no negative number, then all number between 0 to 100 can cover all the input.

Code:

Java

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

C++

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

B. Prinzessin der Verurteilung

Solution:

Enumerate all the possible answer by brute force, and compare with the input string. Until we found the answer match the requirement.
So, we enumerate a,b,c,d,...z first. Then enumerate aa,ab,ac,ac,...az,ba,bb,...zz. And so on.

Why can enumerate by brute force? Consider all two letter combinations, there are 26*26=676 ways. So if all these can be found in the input string, then the length of input string is around 676*2=1352. (Note that, just around 1352. Because the input string can be aab, and zb can be covered by azba.)

Code:

Java

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

C++

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

C. Diluc and Kaeya

Solution:

Not hard to find that: if there are two part of string, one ratio is 3:1, and another one is 6:2=3:1. If we put them together, the ratio is 9:3=3:1.

So, for any position, we just need check the number of position before which the ratio is equal to current position.

Code:

Java

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

C++

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

D. Omkar and Medians

In fact, for a new b, because there only have two new number join, so the impact of the median at most 1 number.

Codeforces Round #724 Omkar and Medians Solution (Java/C++)
Solution:First, we can find that: for b[i+1], compare to b[i], actually, we add two number to a: a[2i+1] and a[2i]. So, the impact to the median is limited to 1 position.
Click the link above for more detail solution

E. Omkar and Forest

In fact, we can find that, the value of point which is not 0 is decided by the point of 0. So just need choose some point from '#' to be 0.

Codeforces Round #724 Omkar and Forest Solution (Java/C++)
Solution:There are two conclusions:For any point of the map, assume the value of this point is x. So, there must a path from this point, and the value of
Click the link above for more detail solution
DigitalOcean Referral Badge 蜀ICP备19018968号