公式

G - Random Subtraction 解説 by en_translator

Another Solution

\(C_N\) can be found in \(O(1)\) time.
In fact, we have \(C_N=\begin{cases} 0 \; (N=1)\\ -1 \; (N=2)\\ \frac{-N}{3} \; (3 \leq N). \end{cases}\)
While this can be proven inductively, we will introduce another interpretation.

Let \(3 \leq N\).
Given vertices \(1,2,\dots,N\), where each connected component \(S\) is assigned an integer \(B(S)\), initially with \(B(\{i\})=A_i\), consider performing the following operation \((N-1)\) times:

  • Choose different connected components \(S\) and \(T\). Add an edge between them, and assign to the new connected component \(S \cup T\) the integer \(B(\{S\})-B(\{T\})\).

We will think about \(c_ic_j\).
Consider the moment when we merge two connected components \(S\) and \(T\) containing \(i\) and \(j\), respectively.
If \(2 \leq |S|\), the probability that \(c_i\) is \(1\) and \(c_i\) is \(-1\) is equal, so the expected value of \(c_ic_j\) is \(0\). If \(2 \leq |T|\), the expected \(c_ic_j\) is \(0\) likewise.
If \(|S|=|T|=1\), then any remaining operations maintain the signs of \(c_i\) and \(c_j\) different, so \(c_ic_j=-1\).
Hence, we see that \(C_N\) equals \(-1\) times the expected number of times we merge size-\(1\) connected components.

We further reinterpret the problem by imposing the following conditions:

  • First, arrange vertices \(1,2,\dots,N\) in a line at random order.
  • Then, without further rearranging them, repeat merging adjacent connected components \((N-1)\) times.:

This modification does not change the probability distributions of the set of connected components after each operation and the operation to be chosen, so \(C_N\) also remains invariant.
For \(i=1,2,\dots,N-1\), assume that two connected components containing vertices \(i\) and \((i+1)\) is merged in the \(P_i\)-th operation.
Then, \((P_1,P_2,\dots,P_{N-1})\) is a permutation of length \((N-1)\), and any such permutation occurs with equal probability.
Let us consider the condition and the probability that \(\{i\}\) and \(\{j\}\) are merged.
For \(2 \leq i \leq N-2\), this is equivalent to \(P_{i-1},P_{i+1}>P_{i}\), which occurs with probability \(\frac{1}{3}\).
For \(i=1\), this is equivalent to \(P_{2}>P_{1}\), which occurs with probability \(\frac{1}{2}\).
For \(i=N-1\), this is equivalent to \(P_{N-2}>P_{N-1}\), which occurs with probability \(\frac{1}{2}\).
Summing them up yields the formula above.

投稿日時:
最終更新: