T231 - Pass Ball Ball

The problem is trivialised when $n$ modulo 4 is considered as the ball goes from Alice to Bob to Carol to Bob, then back to Alice to Bob to Carol to Bob, repeats.
Time complexity: $O(1)$

T232 - Chocolate Coin Debt

Recall that the volume of a cylinder of height $h$ and radius $r$ is given by $\pi \cdot r^2 \cdot h$. Note that the value of $\pi$ can be obtained by acos(-1) and remember to use long double to avoid precision errors.
Time complexity: $O(n)$

T233 - Stars

Group stars by their respective y-coordinates. Precompute the number of stars having a certain x-coordinate. Loop through all possible y-coordinates and exhaust all pair of stars with that y-coordinate as the base of the isosceles triangle. Find the number of stars that can be used as the third vertex of the triangle. Be sure to not count the degenerate case.
Time complexity: $O(n^2)$

T234 - Magical Shuffle

Subtask 1 (15%)

If $M=0$, print $1$ to $2N$ in ascending order.
If $M=1$, print $N+1, 1, N+2, 2, ..., 2N, N$, which can be done by using for loop and if statement.
If $M=2$, store the result of $M=1$ in an array and perform faro-out shuffle to the array.
Time complexity: $O(N)$

Subtask 2 (15%)

Denote $in[i]$ as the $i$-th number after performing faro-in shuffle to $[1, 2, ..., 2N]$.
Denote $out[i]$ as the $i$-th number after performing faro-out shuffle to $[1, 2, ..., 2N]$.
After applying in shuffle to sequence $A$, $A[i]$ becomes $A[in[i]]$ for all $i$, similar for out shuffle.
Repeat this $M$ times and output the result sequence.
Time complexity: $O(NM)$

Subtask 3 (40%)

Denote $par[i]$ as the $i$-th number after performing 1 in and 1 out shuffle to $[1, 2, ..., 2N]$.
Or simply denote $par[i]=out[in[i]]$. We can build a directed graph, where there is an edge from $i$ to $par[i]$, for all $i$.
The task is now find the $M$-th ancestor of each node. Notice that each node will be included in a cycle of at most $2N$ size. For each number $i$, compute $M$ modulo the size of the cycle $i$ belongs to and find the corresponding ancestor. Remember to handle the case when $M$ is odd.
Time complexity: $O(N^2)$

Solution 1

Notice that when we visit a cycle, we can also find the corresponding ancestor for all nodes that are part of the cycle. Therefore, we don't need to revisit the same cycle if we have gone to it. We only need to travel $2N$ nodes in total.
Time complexity: $O(N)$

Solution 2

Raise the $par$ array to $\lfloor M/2 \rfloor$-th power using binary exponentiation, and then apply it to the sequence.
Time complexity: $O(N \log M)$

Fun fact I actually found an article that basically has both full solutions of this task in cp-algorithm, but we use this task anyway XD.
If you read this before, then congratulations, here's 100 free points.
How sad that only 1 ac DX
solution by cp-algorithm

T235 - A Certain Scientific Railgun

Subtask 1 (15%)

Denote $X$, $Y$ and $R$ as the number of different $X_i$, $Y_i$ and $R_i$ respectively.
Notice that optimal $(X_0,Y_0)$ must satisfy the inequality $-100 \le X_0, Y_0 \le 100$. For all possible $(X_0,Y_0)$, iterate through all targets and count the points she can get. Choose the maximum one as the answer.
Time complexity: $O(NXY)$

Subtask 2 (15%)

We can build a 2D array $A$ where $A[i][j]$ represents the point if choosing $(i,j)$ as $(X_0,Y_0)$. For each target, we increase the point of the cells which are covered by the target. The point of $(2R-1)^2$ cells are changed for a target. After that, we can simply output the maximum number in the array.
To deal with negative index, you can increase all coordinates by some constant $c=200$ or use std::unordered_map.
Time complexity: $O(NR^2)$

Subtask 3 (30%)

Notice that the optimal $X_0$ is fixed, so we only need to find the optimal $Y_0$. There are $O(YR)$ different targets only. Instead of storing them independently, we can store them with a frequency array. The rest will be looping all possible $Y_0$ and choose the optimal one.
Time complexity: $O(N+Y^2R)$

Solution

By expanding the idea from Subtask 2, we are trying to maintain an offline 2D submatrix update of some weird pattern.
One of the tools for this is 2D difference array.

Observe the update of a target of $R=3$ is:
    1 2 3 2 1
    2 4 6 4 2
    3 6 9 6 3
    2 4 6 4 2
    1 2 3 2 1
If we express this in 2D difference array, the update will be:
    1 1 1 -1 -1 -1
    1 1 1 -1 -1 -1
    1 1 1 -1 -1 -1
    -1 -1 -1 1 1 1
    -1 -1 -1 1 1 1
    -1 -1 -1 1 1 1

Notice that the update looks like 4 squares of 1 and -1, which can be expressed by another 2D difference array. After iterating all $N$ targets and record the changes, update the array and find the maximum.
Time complexity: $O(N+XY)$

T236 - Rectangles

Subtask 1, 2 (32%)

Exhaust the top-left and bottom-right corners of the rectangle. Loop through all 2 x 2 squares and check if they intersected the rectangle.
Time complexity: $O(n^2 m^2 k)$

Solution

Discretize all 2 x 2 squares and compress the grid into a new grid, with each row and column in the new grid representing one or more rows or columns in the original grid. Since $k \le 10$, we can use the idea from subtask 2 to calculate the answer. Exhaust the top-left and bottom-right corners of the rectangle in the new grid and calculate the number of rectangles in the original grid that corresponds to it by basic combinatorics (split into two cases: same row/column or different row/column).
Time complexity: $O(k^4)$

T237 - Annoying Advertisements Remastered

Subtask 1, 2 (26%)

Do a brute-force search of all paths, keeping track of the door chosen at each stage, then check if one of the paths achieves the objective.
Time complexity: $O(2^N)$

Subtask 3 (25%)

Use the meet-in-the-middle technique. Use the same idea as subtask 1 and 2 to compute the possible values in the first forward half. For the second half, you need to go backwards. At each door you need to solve for $a$ in $[a\ s\ x] = b$ if the current value is $b$. When $s$ is $+, -$, there is only one solution for $a$.

Subtask 4 (14%)

Now $s$ can also be $\times$. Again you solve for $a$, but this time there may be no solutions, in which case you should disregard that path.

Solution

Finally, $s$ can be $\div$. Trying to solve for $a$ now may yield multiple solutions. An observation is that the solutions are always consecutive. Therefore, now we maintain segments of all possible $a$. For backwards segment addition and subtraction, it is trivial. For multiplication and division however needs a bit of case handling. Especially for backwards division, when multiplying two numbers there may be overflow.
Therefore, either use int128_t or multiply(a, b) = min(abs(a), MX/b) * b * (a < 0 ? -1 : 1).
Time complexity: $O(2^{N/2})$

Notes from GL This task is so annoying!
Notes from author Snuny wanted a question that is as tedious as possible ==