問題一覧 > 通常問題

No.3280 Black-Tailed Gull vs Monster

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 89
作問者 : hirayuu_yc / テスター : highlighter
お気に入りにしたユーザー ProblemId : 12192 / 自分の提出
問題文最終更新日: 2025-09-26 21:22:57
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 484 (順位表) の他の問題:

Problem Statement

The Black-Tailed Gull and her companions are about to fight a Cerulean (monster).

Simply put, the Black-Tailed Gull's standby skill makes the opponent unable to act (under certain conditions). How unfair!

However, the skill does not activate if the Black-Tailed Gull herself acts, and its activation chance is halved if there is a Friend who acts multiple times.

$N$ Friends fight a Cerulean.

The Friends are numbered $1,2,\dots,N$, and Friend $X$ is the Black-Tailed Gull. No other Friend is the Black-Tailed Gull.

The battle lasts for $Q$ turns. In turn $i$, $M_i$ actions are performed. Specifically, Friends $F_{i,1},F_{i,2}\dots,F_{i,M_i}$ act in this order.

Whether the Cerulean acts in turn $i$ is determined as follows.

  • If the Black-Tailed Gull acted at least $1$ time in turn $i$, the Cerulean always acts $1$ time.
  • Otherwise, if there is a Friend who acted $2$ or more times in turn $i$, the Cerulean acts $1$ time with probability $\frac{1}{2}$ and does not act with probability $\frac{1}{2}$.
  • If neither of the above applies, the Cerulean never acts.

Find the expected number of times the Cerulean acts. Whether the Cerulean acts is determined independently for each turn. Also, both the Friends and the Cerulean are sufficiently strong, and none of them will be defeated before $Q$ turns have passed.

Constraints

  • $1\leq X\leq N\leq 10^9$
  • $1\leq Q$
  • $1\leq M_i$
  • $\sum_{i=1}^{Q}M_i\leq 2\times 10^5$
  • $1\leq F_{i,j}\leq N$
  • All input values are integers.

Input

$N$ $X$ $Q$
$M_1$
$F_{1,1}$ $F_{1,2}$ $\dots$ $F_{1,M_1}$
$M_2$
$F_{2,1}$ $F_{2,2}$ $\dots$ $F_{2,M_2}$
$\vdots$
$M_Q$
$F_{Q,1}$ $F_{Q,2}$ $\dots$ $F_{Q,M_Q}$

Output

Output the answer. Your answer is judged as correct if its absolute or relative error from the correct answer is at most $10^{-5}$.

Sample

Sample 1
Input
10 1 3
3
1 2 1
3
3 3 4
3
9 2 4
Output
1.5
  • In turn $1$, the Black-Tailed Gull acts, so the Cerulean always acts $1$ time.
  • In turn $2$, the Black-Tailed Gull does not act, but Friend $3$ acts multiple times, so the Cerulean acts $1$ time with probability $\frac{1}{2}$ and does not act with probability $\frac{1}{2}$.
  • In turn $3$, the Black-Tailed Gull does not act and no Friend acts multiple times, so the Cerulean never acts.

The expected number of actions is $1.5$. Outputs such as 1.499999999 or 1.500000001 are also judged as correct.

Sample 2
Input
5 2 4
3
1 3 4
3
3 5 4
4
5 4 1 3
3
3 1 4
Output
0

If the Cerulean never acts, victory is guaranteed. Unfair indeed!

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。