Official

Overall Editorial by evima

Hints

A - Replace C or Swap AB

Hint 1 First, let's consider the case where there is no C. Then, Operation (3) can be easily understood by focusing only on A and thinking of it as moving one A to the right.
Hint 2 Next, let's consider how to handle C. Noting that no new C is created by the operations, we can reduce the problem to the case where $Y$ does not contain C. Then, we can greedily determine which C should be converted to which of A and B.

Editorial: https://atcoder.jp/contests/arc166/editorial/7375


B - Make Multiples

Hint 1 The editorial introduces two solutions: using dynamic programming, and narrowing down the candidates for the operation and then performing a brute-force search.

Editorial: https://atcoder.jp/contests/arc166/editorial/7376


C - LU / RD Marking

Hint 1 Let's divide the entire grid edges into several subsets that can be treated independently.
Hint 2 There will be a formula that seems to take $O(H+W)$ time to calculate, but you can speed up the calculation per test case with appropriate precomputation.

Editorial: https://atcoder.jp/contests/arc166/editorial/7377


D - Interval Counts

Hint 1 We may limit ourselves to choosing as large intervals that cover some set of points as possible. Then, $L_j$ can be limited to values such as $x_i+1$, and $R_j$ can be limited to values such as $x_i-1$.
Hint 2 For each $i$, you can give lower bounds for the number of $j$ such that $L_j=x_i+1$ and the number of $j$ such that $R_j=x_{i}-1$. From there, you can construct a solution by the minimum number of intervals, which can be proved optimal.

Editorial: https://atcoder.jp/contests/arc166/editorial/7378


E - Fizz Buzz Difference

Hint 1 You only need to consider the maximal good pairs. Then, it can be proved that $L-1$ and $R+1$ are multiples of $a$.
Hint 2 Consider the case where $L=al+1, R=ar-1$. The number of multiples of $b$ included in this interval can be calculated from $(al\bmod b)$. When $r-l$ is fixed, the number of multiples of $b$ is maximized when $(al\bmod b)=b-\gcd(a,b)$.
Hint 3 This problem can be reduced to the type of problem that asks, "Given $a, b, c$, find the smallest $x$ such that $(ax\bmod b)\geq c$". This can be solved in $O(\log b)$ time.

Editorial: https://atcoder.jp/contests/arc166/editorial/7379


F - Tangent Addition Formula

Hint 1 The problem is based on the equation satisfied by $t(x)=\tan(x)$. Keeping in mind the similarity with $\tan(x)$ will make it easier to consider the problem.
Hint 2 Using the complex exponential function, we can see that there are $i, r$ such that $\tan(x) = i\cdot\frac{1-r^x}{1+r^x}$. For the $t(x)$ in this problem as well, let's show that it has a representation like $t(x) = i\cdot\frac{1-r^x}{1+r^x}$, except for some exceptions.
Hint 3 In the case of $p\equiv 1\pmod{4}$, we can solve the problem by considering the equation $t(x) = i\cdot \frac{1-r^x}{1+r^x}$ with a number $i$ that satisfies $i^2=-1$. On the other hand, in the case of $p\equiv 3\pmod{4}$, we cannot consider $i\in \mathbb{F}_p$ that satisfies $i^2=-1$. However, by adding a new $i$ that satisfies $i^2=-1$ and considering it (just as the real function $\tan(x)$ can be expressed using complex numbers), we can solve the problem in the same way as in the case of $p\equiv 1\pmod{4}$.

Editorial: https://atcoder.jp/contests/arc166/editorial/7380

posted:
last update: