#P7495. Divine Loyalty Test

    ID: 20690 Type: Default 1000ms 256MiB

Divine Loyalty Test

Divine Loyalty Test

The Almighty wants to test the loyalty of His followers using a twist of fate. He has prepared a binary string aa of length nn, representing His predetermined choices for nn questions. Each question has two options: the "more radical" option (denoted by 1) and the "more conservative" option (denoted by 0).

He chooses a contiguous block of kk questions from aa, where kk is chosen uniformly at random from the range [l,r][l, r]. Then, a follower answers these kk questions by replying with a binary string bb of length kk, where each bit is chosen independently and uniformly (0 or 1).

For a fixed block (with God’s choices pp and follower’s answers qq of length kk), we say that qq is loyal to pp if the following condition holds for every 2ik2 \le i \le k:

[ \text{if } q_{i-1} = p_{i-1} \text{ then } q_i \ge p_i, \quad \text{else } q_i \le p_i. ]

Note that for the first question, loyalty is always granted.

Your task is to calculate the probability that a follower is loyal. In other words, first a length kk (with lkrl\le k\le r) is chosen uniformly, then a contiguous substring of aa of length kk is chosen uniformly, and finally a binary string bb of length kk is chosen uniformly (each bit is 0 or 1 with equal probability). Compute the probability that bb is loyal to the chosen substring of aa. Since the answer may be a rational number, output it modulo (998244353) (using modular inverses when necessary).

All formulas must be written in ( \LaTeX ) format. For example, the condition above is given by

[ \forall; 2 \le i \le k,\quad \text{if } q_{i-1}=p_{i-1}\text{ then } q_i\ge p_i\text{, otherwise } q_i\le p_i. ]

It is guaranteed that the input is such that the answer is well–defined.

inputFormat

The first line contains three integers (n), (l), and (r) (with (1 \le l \le r \le n)). The second line contains a binary string (a) of length (n).

outputFormat

Output a single integer, the probability (modulo (998244353)) that a randomly chosen follower (as described) is loyal.

sample

4 1 2
1010
748683265

</p>