Codeforces Round #896 (Div. 2) ABCDE Solutions (Java/C++)

A. Make It Zero Solution: If we XOR all the numbers together, for each bit, if there were originally an odd number of 1s in that bit, the result will be 1; otherwise, it will be 0.…

Codeforces Round #896 Travel Plan Solution (Java/C++)

Solution: For convenience, let's first define some functions and variables: $len(i,j)$ represents the number of nodes visited from node $i$ to node $j$ along the entire path. For example, in Sample 1, $len(2,3)=3$, $len(1,2)=1$.…

Codeforces Round #891 (Div. 3) ABCDEFG Solutions (Java/C++)

A. Array Coloring Solution: It is only possible to divide the array into two groups with the same parity if the total sum is even. Code: Java…

Codeforces Round 893 (Div. 2) ABCD Solutions (Java/C++)

A. Buttons Solution: Both players will prioritize button $c$. So, Anna can win an additional point if and only if $c$ is odd. Then, it only matters if $a-b$ is greater than zero.…

Codeforces Round #894 (Div. 3) ABCDEFG Solutions (Java/C++)

A. Gift Carpet Solution： Simply match column by column. Code： Java…

Codeforces: Why You Should Avoid Using comparingX or thenComparingX in Java's Comparator Class

Background Suppose you need to sort an array or have a TreeSet that requires a specific order. Let's take the following class as an example:…

Codeforces Round #895 (Div. 3) ABCDEFG Solutions (Java/C++)

A. Two Vessels Solution: The data size is very small, all within 100. So, you can simply simulate pouring water from the larger vessel to the smaller one step by step. Code: Java C++…

Codeforces Round #828 (Div. 3) ABCDEF Solutions (Java/C++)

A. Number Replacement Solution: Obviously each number can only be replaced by the same letter, so we only need to open a Map to check whether any number has been replaced by two different letters.…