Thank you for participating in this round! Problems I are authored by orzdevinwang and the rest by me.
Sorry for the weak pretest in problem B.
hints and code are WIP.
What is the parity of $$$s$$$ after an operation?
After the first operation, $$$s$$$ is always odd. You can only earn points when $$$a_i$$$ is odd after this operation. However, during the first operation, you can only earn a point if $$$a_i$$$ is even.
Let $$$c_0$$$ and $$$c_1$$$ be the number of even and odd numbers, respectively.
If there is at least one even number, you can place it first, making the answer $$$c_1 + 1$$$. Otherwise, since no points can be earned during the first operation, the answer is $$$c_1 - 1$$$.
Time complexity: $$$O(n)$$$.
Let $$$a$$$ and $$$b$$$ be the lengths of the two bases, and let $$$c$$$ be the length of the two legs. A necessary and sufficient condition for forming an isosceles trapezoid with a positive area is $$$|a - b| < 2c$$$, as the longest edge must be shorter than the sum of the other three edges.
To determine whether an isosceles trapezoid can be formed, consider the following cases:
- If there are two distinct pairs of identical numbers that do not overlap, these pairs can always form an isosceles trapezoid.
- If there are no pairs of identical numbers, it is impossible to form an isosceles trapezoid.
- If there is exactly one pair of identical numbers, denoted by $$$c$$$, we will use them as the legs. Remove this pair and check whether there exist two other numbers whose difference is less than $$$2c$$$. This can be efficiently done by sorting the remaining numbers and checking adjacent pairs. \end{itemize}
The time complexity of this approach is $$$O(n \log n)$$$.
For the $$$i$$$-th person, there are at most two possible cases:
- If they are honest, there are exactly $$$a_i$$$ liars to their left.
- If they are a liar, since two liars cannot stand next to each other, the $$$(i-1)$$$-th person must be honest. In this case, there are $$$a_{i-1} + 1$$$ liars to their left. \end{itemize}
Let $$$dp_i$$$ represent the number of possible game configurations for the first $$$i$$$ people, where the $$$i$$$-th person is honest. The transitions are as follows:
- If the $$$(i-1)$$$-th person is honest, check if $$$a_i = a_{i-1}$$$. If true, add $$$dp_{i-1}$$$ to $$$dp_i$$$.
- If the $$$(i-1)$$$-th person is a liar, check if $$$a_i = a_{i-2} + 1$$$. If true, add $$$dp_{i-2}$$$ to $$$dp_i$$$. \end{itemize}
The final answer is given by $$$dp_n + dp_{n-1}$$$.
Time complexity: $$$O(n)$$$.