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 m rounds. In the i-th round, the following events occur:
- a card with the value ai is added to the deck (it is guaranteed that no card with this value was previously in the deck);
- if there are fewer than 3 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−2 cards uniformly at random;
- at the end, all three chosen cards are returned to the deck.
Let a be the value on Alice's card, b be the value on Bob's card, and c be the value on the randomly chosen card. Then Bob receives:
- 0 points if ∣a−c∣≤∣b−c∣ (where ∣x∣ denotes the absolute value of x);
- 0 points if card c is between cards a and b (i. e., a<c<b or b<c<a);
- ∣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 998244353.
Note that the players minimize or maximize the real value of the expected score, not the result taken modulo 998244353.
Alice 和 Bob 有一副初始为空的纸牌。他们进行一场持续 m 轮的游戏。在第 i 轮中,发生以下事件:
- 一张值为 ai 的纸牌被加入牌堆(保证此前牌堆中不存在值为 ai 的纸牌);
- 若牌堆中纸牌数量少于 3 张,则本轮结束;
- 否则,Alice 从牌堆中选择一张纸牌;
- 接着,Bob 在已知 Alice 所选纸牌的前提下,从牌堆中选择一张纸牌(不能与 Alice 所选为同一张);
- 然后,从剩余的 i−2 张纸牌中均匀随机选择一张纸牌;
- 最后,这三张被选出的纸牌全部归还至牌堆。
设 Alice 所选纸牌的值为 a,Bob 所选纸牌的值为 b,随机选出的纸牌的值为 c。那么 Bob 获得的分数为:
- 若 ∣a−c∣≤∣b−c∣(其中 ∣x∣ 表示 x 的绝对值),则得 0 分;
- 若纸牌 c 位于纸牌 a 与 b 之间(即 a<c<b 或 b<c<a),则得 0 分;
- 其他情况下,得 ∣b−c∣ 分。
在每一轮中,Alice 的目标是使 Bob 的期望得分最小化,而 Bob 的目标是使该期望得分最大化。若双方均以最优策略进行游戏,则 Bob 在每一轮中的期望得分是多少?请输出该期望得分对 998244353 取模的结果。
注意:双方优化的是期望得分的真实数值,而非其对 998244353 取模后的结果。
输入格式
The first line contains a single integer (3≤m≤2⋅105) — the number of rounds.
The second line contains m integers a1,a2,…,am (1≤ai≤1012; all ai are distinct).
第一行包含一个整数 m(3≤m≤2⋅105)—— 表示回合数。
第二行包含 m 个整数 a1,a2,…,am(1≤ai≤1012;所有 ai 互不相同)。
输出格式
Print m−2 integers: the i-th number should be equal to the expected score for Bob in the round i+2 with optimal play from both players modulo 998244353 (i. e., let the expected score be an irreducible fraction yx; you need to output x⋅y−1mod998244353, where y−1 is such a number that y⋅y−1mod998244353=1).
Note that the players minimize or maximize the real value of the expected score, not the result taken modulo 998244353.
输出 m−2 个整数:其中第 i 个数应等于在双方均采取最优策略的前提下,Bob 在第 i+2 轮中的期望得分(对 998244353 取模)。即:设该期望得分为既约分数 yx,则需输出 x⋅y−1mod998244353,其中 y−1 是满足 y⋅y−1mod998244353=1 的数。
注意:双方玩家优化的是期望得分的实际数值,而非其对 998244353 取模后的结果。
输入输出样例
输入#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,21,32.
In the second example, the answers are: 0,21,1,45.
In the third example, the answers are: 0,23,2,23,58,611,711.
在第一个例子中,答案为:0,21,32。
在第二个例子中,答案为:0,21,1,45。
在第三个例子中,答案为:0,23,2,23,58,611,711。
输入解题思路,AI测评打分。不知道怎么写?