No.2964 Obstruction Bingo
タグ : / 解いたユーザー数 39
作問者 :
Story
A nostalgic memory: going home dejected because the numbers I wanted never came out of the lottery box at all.Is some kind of "greed sensor" at work, I wonder?
It goes without saying that it is better when winning draws come easily.
Problem Statement
Nana and Minsa have strings of lowercase English letters $S=S_0S_1 \cdots S_{L-1}$ and $T=T_0T_1 \cdots T_{L-1}$, respectively, each of length $L$.
There is also a lottery box containing lottery cards: it contains $a_i$ cards of the $i$-th lowercase English letter from the front $(1 \leq i \leq 26)$. Each lottery card is chosen with equal probability and is returned after each trial; that is, the probability that the $i$-th lowercase English letter from the front $(1 \leq i \leq 26)$ is chosen is $\frac{a_i}{\sum_{j=1}^{26}a_j}$.
Initially, both players' scores are $0$; that is, letting $P_N$ be Nana's score and $P_M$ be Minsa's score, $P_N=P_M=0$. The following action is repeated until the outcome is decided or it has been performed $K$ times.
If the outcome is not decided, the game is a draw. Find the winning probabilities of Nana and Minsa, each in $\text{mod}$ $998244353$.
That is, each of these probabilities is a rational number whose irreducible fraction representation has a denominator coprime to $998244353$, so when the answer is $\frac{P}{Q}$ as an irreducible fraction, find the integer $x(0 \leq x \leq 998244352)$ such that $Qx \equiv P$ $(\text{mod}$ $998244353)$.
Input
$L$ $K$
$S$
$T$
$a_1$ $a_2$ $\cdots$ $a_{26}$
Output
Letting $X$ be the probability that Nana wins and $Y$ be the probability that Minsa wins, output them as follows.
$X$ $Y$
Sample
Sample 1
Input
2 2 ab cd 2 3 2 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Output
148499160 197998880
Nana's winning probability is $\frac{6}{121}$, and Minsa's winning probability is $\frac{8}{121}$.
Sample 2
Input
4 10 abcd bcde 0 2 5 2 5 2 5 2 5 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Output
0 798178412Since
a never comes up, Nana can only stand by helplessly and watch whether her opponent finishes.
Sample 3
Input
5 100 ahjnp ahjnp 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
Output
0 0
No difference in scores ever arises, so the outcome is never decided.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。