Official

Overall Editorial by evima


Here are hints for all problems.


A - Repdigit Number

Hint 1 How many integers less than $10^N$ are there whose digits in the decimal notation are all the same?
Hint 2 There are $9N$ integers less than $10^N$ whose digits in the decimal notation are all the same. For each of them, compute the remainder when it is divided by $M$.
Hint 3 The remainder for an $n$-digit number can be computed in $O(1)$ time by using the remainder for an $(n-1)$-digit number.

Editorial → https://atcoder.jp/contests/arc149/editorial/4953


B - Two LIS Sum

Hint 1 You need to know beforehand that the LIS of an $N$-term sequence can be computed in $O(N\log N)$ time, which is used in this problem.
Hint 2 Being able to swap adjacent tuples $(A_i, B_i)$ means you can freely rearrange the $N$ tuples $(A_i, B_i)$. Let us first fix the set of tuples whose $A_i$ and $B_i$ are both used in the LIS and then consider the properties of the optimal arrangements.
Hint 3 We can prove that in an optimal solution, for any $i$, at least one of $A_i$ and $B_i$ is used as a term of a LIS. We can also prove that there is an optimal solution where $A$ is in ascending order.

Editorial → https://atcoder.jp/contests/arc149/editorial/4954


C - Avoid Prime Sum

Hint 1 Any even number not less than $4$ is not prime.
Hint 2 By filling the upper half of the grid with odd numbers and the lower half with even numbers, almost all sums of two adjacent numbers will be an even number not less than $4$.
Hint 3 Let us fill the upper half of the grid with odd numbers and the lower half with even numbers. The objective will be achieved if the border between odd numbers and even numbers always makes a sum that is a multiple of $3$ not less than $6$.

Editorial → https://atcoder.jp/contests/arc149/editorial/4955


D - Simultaneous Sugoroku

Hint 1 Let us assume that there are pieces at all initial positions $1, 2, \ldots, 10^6$ and find the outcome for all pieces.
Hint 2 Use the following fact: for two pieces that are at coordinates $x$ and $-x$ at some time, we can use the outcome for one of them to find the outcome for the other.
Hint 3 For two pieces that are at coordinates $x$ and $-x$ at some time, simulate just one of them and use its outcome to find the answer for the other. If we trace the pieces on just one of the sides $x>0$ and $x<0$, the next movements can be described without division into cases.
Hint 4 See this image.

Editorial → https://atcoder.jp/contests/arc149/editorial/4956


E - Sliding Window Sort

Hint 1 It is a little confusing that the sorted interval slides. It might be easier to fix the position of the sorted interval and rephrase the problem into one with circular shifts.
Hint 2 When $K$ is very large, the change of the sequence is rather simple. Experiments with specific sequences might help.
Hint 3 The problem can be reduced to the case $M+K-1=N$.

Editorial → https://atcoder.jp/contests/arc149/editorial/4957


F - Rational Number System

Hint 1 The unique existence of the expansion can be proved by considering the digits one by one from the "$r^0$s place." We can also see that a prefix of the base-$r$ expansion of $n$ is the base-$r$ expansion of another number.
Hint 2 The lexicographical order on a set of strings matches the pre-order when performing DFS on a trie.
Hint 3 We can search for the $L$-th, $\ldots$, $R$-th nodes fast if we can compute the number of nodes in a subtree in a trie, etc. Let us count the nodes at the same depth together.

Editorial → https://atcoder.jp/contests/arc149/editorial/4959

posted:
last update: