Codeforces Round #742 Non-Decreasing Dilemma Solution (Java/C++)
Solution: This problem is a typical application of segment tree. As shown in the figure below, we maintain three attributes for each interval:…
Solution: This problem is a typical application of segment tree. As shown in the figure below, we maintain three attributes for each interval:…
A. The Miracle and the Sleeper Solution: Obviously, when b=r/2+1, the value of a%b is the largest. Of course, note that the value of b cannot be less than l.…
Solution: First, we define $b[i]=a[i]\cdot (-1)^{(i-1)}$, $sum(l,r)=\sum_{i=l}^r{b[ i]}$. So for any i, b[i] is either 1 or -1. Therefore, if the final sum is 0, then there must be the same number of 1 as the number of -1.…
Solution: First of all, it is obvious that if the 1, 4, 6, 8, 9 appear in the original number. All other numbers can be deleted, and only one digit is left.…
A. Simply Strange Sort Solution: This question can be simulated according to the requirements of the question. Code: Java C++…
A. Dislike of Threes Solution: Just check each number in turn starting from 1. Code: Java C++…
A. Mocha and Math Solution: Because $a\&b\leq a$. So, the answer is $a_1\&a_2\&a_3\&...\&a_n$. Code: Java C++…
Solution: First, it is obvious that we will use "Disjoint-set data structure" to determine whether two points are in the same tree.…