P6046

题意

链接

\(n\) 个物品排成一列,第 \(i\) 个物品强度为 \(a_i\)。每一秒会随机选择两个相邻的物品相撞,强度较小的那个会破碎,被移除队列(即原本不相邻的物品可能会现在相邻)。求每个物品存活时间的期望。

$O(n^2) $ 解法

\(P(i=x)\) 为某物品存活时间等于 \(i\) 的概率,则显然 \(E=\sum\limits_{i=1}^{n-1}iP(i=x)\)

展开来就是

\[\begin{align} E&=P(1=x)+2P(2=x)+3P(3=x)+...\\ &=(P(1=x)+P(2=x)+P(3=x)+...)+(P(2=x)+P(3=x)+...)+(P(3=x)+...)+...\\ &=P(1\le x)+P(2\le x)+P(3\le x)+...\\ &=\sum_{i=1}^{n-1}P(i\le x) \end{align} \]

重申 \(\large E=\sum_\limits{i=1}^{n-1}P(i\le x)\)

于是设 \(pre\) 为在物品 \(x\) 左边第一个强度比它大的物品, \(nxt\) 为在物品 \(x\) 右边第一个强度比它大的物品。则如果 \(pre\sim x\) 一段物品或 \(x\sim nxt\)​ 一段物品全部被打碎,则这个物品就碎了。

\(P(A)\)\(pre\sim x\) 全部破碎的概率, \(P(B)\)\(x\sim nxt\) 全部破碎的概率。则 \(P(A\and B)\)\(pre\sim nxt\) 全部破碎的概率。

\(P(i\ge x)=P(A)+P(B)-P(A\and B)\)

\(d_1=x-pre,d_2=nxt-x\)​,有 \(P(i\le x)=1-P(A)-P(B)+P(A\and B)=1-\frac{\left(\begin{array}{c} n-1-d_{1} \\ i-d_{1} \end{array}\right)}{\left(\begin{array}{c} n-1 \\ i \end{array}\right)}-\frac{\left(\begin{array}{c} n-1-d_{2} \\ i-d_{2} \end{array}\right)}{\left(\begin{array}{c} n-1 \\ i \end{array}\right)}+\frac{\left(\begin{array}{c} n-1-d_{1}-d_{2} \\ i-d_{1}-d_{2} \end{array}\right)}{\left(\begin{array}{c} n-1 \\ i \end{array}\right)}\)

posted @ 2021-08-15 16:59  BlankAo  阅读(126)  评论(0编辑  收藏  举报