CF2203E.Probabilistic Card Game

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob have a deck of cards, which is initially empty. They play a game that lasts for mm rounds. In the ii-th round, the following events occur:

  • a card with the value aia_i is added to the deck (it is guaranteed that no card with this value was previously in the deck);
  • if there are fewer than 33 cards in the deck, the round ends;
  • otherwise, Alice chooses a card from the deck;
  • then Bob chooses a card (knowing which card Alice chose; he cannot choose the same one);
  • one more card is chosen from the remaining i−2i-2 cards uniformly at random;
  • at the end, all three chosen cards are returned to the deck.

Let aa be the value on Alice's card, bb be the value on Bob's card, and cc be the value on the randomly chosen card. Then Bob receives:

  • 00 points if ∣a−c∣≤∣b−c∣|a - c| \le |b - c| (where ∣x∣|x| denotes the absolute value of xx);
  • 00 points if card cc is between cards aa and bb (i. e., a<c<ba \lt c \lt b or b<c<ab \lt c \lt a);
  • ∣b−c∣|b-c| points otherwise.

Alice's goal in each round is to minimize Bob's expected score, while Bob's goal is to maximize it. What will be the expected score for Bob in each round if both Alice and Bob play optimally? Print the expected score modulo 998 244 353998\,244\,353.

Note that the players minimize or maximize the real value of the expected score, not the result taken modulo 998 244 353998\,244\,353.

Alice 和 Bob 有一副初始为空的纸牌。他们进行一场持续 mm 轮的游戏。在第 ii 轮中,发生以下事件:

  • 一张值为 aia_i 的纸牌被加入牌堆(保证此前牌堆中不存在值为 aia_i 的纸牌);
  • 若牌堆中纸牌数量少于 33 张,则本轮结束;
  • 否则,Alice 从牌堆中选择一张纸牌;
  • 接着,Bob 在已知 Alice 所选纸牌的前提下,从牌堆中选择一张纸牌(不能与 Alice 所选为同一张);
  • 然后,从剩余的 i−2i-2 张纸牌中均匀随机选择一张纸牌;
  • 最后,这三张被选出的纸牌全部归还至牌堆。

设 Alice 所选纸牌的值为 aa,Bob 所选纸牌的值为 bb,随机选出的纸牌的值为 cc。那么 Bob 获得的分数为:

  • 若 ∣a−c∣≤∣b−c∣|a - c| \le |b - c|(其中 ∣x∣|x| 表示 xx 的绝对值),则得 00 分;
  • 若纸牌 cc 位于纸牌 aa 与 bb 之间(即 a<c<ba \lt c \lt b 或 b<c<ab \lt c \lt a),则得 00 分;
  • 其他情况下,得 ∣b−c∣|b-c| 分。

在每一轮中,Alice 的目标是使 Bob 的期望得分最小化,而 Bob 的目标是使该期望得分最大化。若双方均以最优策略进行游戏,则 Bob 在每一轮中的期望得分是多少?请输出该期望得分对 998 244 353998\,244\,353 取模的结果。

注意:双方优化的是期望得分的真实数值,而非其对 998 244 353998\,244\,353 取模后的结果。

输入格式

The first line contains a single integer (3≤m≤2⋅1053 \le m \le 2 \cdot 10^5) — the number of rounds.

The second line contains mm integers a1,a2,…,ama_1, a_2, \dots, a_m (1≤ai≤10121 \le a_i \le 10^{12}; all aia_i are distinct).

第一行包含一个整数 mm(3≤m≤2⋅1053 \le m \le 2 \cdot 10^5)—— 表示回合数。

第二行包含 mm 个整数 a1,a2,…,ama_1, a_2, \dots, a_m(1≤ai≤10121 \le a_i \le 10^{12};所有 aia_i 互不相同)。

输出格式

Print m−2m-2 integers: the ii-th number should be equal to the expected score for Bob in the round i+2i+2 with optimal play from both players modulo 998 244 353998\,244\,353 (i. e., let the expected score be an irreducible fraction xy\frac{x}{y}; you need to output x⋅y−1 mod 998 244 353x \cdot y^{-1} \bmod 998\,244\,353, where y−1y^{-1} is such a number that y⋅y−1 mod 998 244 353=1y \cdot y^{-1} \bmod 998\,244\,353 = 1).

Note that the players minimize or maximize the real value of the expected score, not the result taken modulo 998 244 353998\,244\,353.

输出 m−2m-2 个整数:其中第 ii 个数应等于在双方均采取最优策略的前提下,Bob 在第 i+2i+2 轮中的期望得分(对 998 244 353998\,244\,353 取模)。即:设该期望得分为既约分数 xy\frac{x}{y},则需输出 x⋅y−1 mod 998 244 353x \cdot y^{-1} \bmod 998\,244\,353,其中 y−1y^{-1} 是满足 y⋅y−1 mod 998 244 353=1y \cdot y^{-1} \bmod 998\,244\,353 = 1 的数。

注意:双方玩家优化的是期望得分的实际数值,而非其对 998 244 353998\,244\,353 取模后的结果。

输入输出样例

  • 输入#1

    5
    1 10 3 11 7

    输出#1

    0
    499122177
    665496236
  • 输入#2

    6
    23 7 11 24 10 28

    输出#2

    0
    499122177
    1
    748683266
  • 输入#3

    9
    4 10 7 1 16 5 9 12 2

    输出#3

    0
    499122178
    2
    499122178
    798595484
    831870296
    427819010

说明/提示

In the first example, the answers are: 0,12,230, \frac{1}{2}, \frac{2}{3}.

In the second example, the answers are: 0,12,1,540, \frac{1}{2}, 1, \frac{5}{4}.

In the third example, the answers are: 0,32,2,32,85,116,1170, \frac{3}{2}, 2, \frac{3}{2}, \frac{8}{5}, \frac{11}{6}, \frac{11}{7}.

在第一个例子中,答案为:0,12,230, \frac{1}{2}, \frac{2}{3}。

在第二个例子中,答案为:0,12,1,540, \frac{1}{2}, 1, \frac{5}{4}。

在第三个例子中,答案为:0,32,2,32,85,116,1170, \frac{3}{2}, 2, \frac{3}{2}, \frac{8}{5}, \frac{11}{6}, \frac{11}{7}。

输入解题思路,AI测评打分。不知道怎么写?

首页