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
C++
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
C++
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
C++
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.
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.