Since once hasn't been released, and I love procrastinating on stuff that I probably should have already finished, I thought I might make one. I also don't know why the links to the problems aren't working, blame CF. Apologies if anything is unclear, I'm tired.
[contest:2218A]
Since $$$min(x, y) \lt = x$$$, and $$$x \leq 67$$$, we can set $$$y = 67$$$, so $$$min(x, y)$$$ will always equal $$$x$$$
[contest:2218B]
The optimal choice is to multiply every value except the largest value by -1, since they have the least contribution to the sum.
[contest:2218C]
For a given "block" of length 3, we will be "wasting" the largest and smallest element in our block. In order to maximize the sum of the medians of the block, we note that the largest element in an array can never be the median, so we pair the largest element with the second largest element so that the second largest element is the median, and finally pair those with the smallest element. Repeat until no more elements are in the array.
[contest:2218D]
Let $$$p_i$$$ denote the $$$i$$$-th largest prime. $$$gcd(p_i * p_{i+1}, p_{i+1} * p_{i+2}) = p_{i+1}$$$, so if we output the products of adjacent primes, then the sequence formed by our gcds will be monotonically increasing, and therefore contain no duplicates. The primes can be generated using a sieve, but make sure to use 64 bit integers.
It can also be shown that outputting adjacent odd numbers has the same result, but I didn't come up with that in contest.
[contest:2218E]
Note that $$$x \oplus x = 0$$$. Using this fact, we can show that only the last operation has any effect. To prove this, consider any operation that is not the last operation. Let $$$x$$$ be the selected value in the operation. If $$$a_i$$$ is set to $$$a_i \oplus x$$$ for all $$$i$$$, then the next operation will have a selected value of $$$a_j \oplus x$$$, meaning each element will be set to $$$a_i \oplus a_j \oplus x \oplus x$$$ since every element was XORed with $$$x$$$ in the previous operations. This means that the $$$x$$$s cancel out, and we're left with $$$a_i \oplus a_j$$$.
Using this, we can simply find the maximum XOR of any pair of elements in $$$O(N^2)$$$ time.
[contest:2218F]
For any arbitrary tree, We can show that the number of nodes where its subtree size is even $$$\leq$$$ the number of nodes where its subtree size is odd. For any node with an even number of nodes in its subtree, it must have at least one child node, and that child node's subtree size will be odd. Therefore, $$$x \leq y$$$.
If $$$x = 0$$$, then $$$y \mod 2$$$ must be $$$1$$$ trivially. For this case, just output a star graph with all nodes connected to node $$$1$$$.
Otherwise, the following construction always works: Output $$$2 \cdot x$$$ nodes such that node $$$i$$$ is connected to node $$$i+1$$$. We now have $$$x$$$ nodes with an even subtree size and $$$y$$$ nodes with an odd subtree size. Finally, to get rid of the remaining $$$y - x$$$ nodes, we can attach them to node $$$1$$$ (if $$$y - x$$$ is even) or node $$$2$$$ (if $$$y - x$$$ is odd).
[contest:2218G]
Let $$$s_i$$$ be the number of people sitting down after the $$$i$$$-th second (i will be using seconds since its simpler to write). First, seat everyone who sits down at time $$$0$$$. Then, iterate over seats in the order of the time when they sit down.
Let the current seat be $$$x$$$ and the current second be $$$t$$$. Additionally, let $$$b$$$ be the first second when one of $$$x$$$'s neighbors sits down.
If none of the neighbors of $$$x$$$ have sat down before $$$t$$$, there is no possible array.
If $$$t = b + 1$$$, then we can assume that the reason why person $$$x$$$ didn't sit down was because none of their neighbors were sitting down, so $$$a_x$$$ can be anything between $$$1$$$ and $$$s_{t-1}$$$.
Otherwise, $$$a_x$$$ must be between $$$s_{t-2} + 1$$$ and $$$s_{t-1}$$$, since the reason why person $$$x$$$ didn't sit down was because they were waiting for more people to sit down.
Since the $$$a_x$$$'s are independent of eachother (the only thing that matters is when they sit down), we can simply multiply all the possibilities together.
(note, my implementation for this problem was really bad, I kinda overcomplicated it in my head) 369716131








