QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 512 MB Total points: 100

#12302. 不公平的卡牌堆

Statistics

在另一款纸牌游戏中,有几种不同类型的牌,总共 30 张。对于每种类型的牌,牌堆中要么只有一张该类型的牌,要么有两张。初始时,牌堆会被洗牌。之后,牌会一张一张地从牌堆中随机抽出,直到抽完为止。

在玩了 100 000 局游戏后,你注意到发牌员发牌并不公平。他没有随机抽取下一张牌,而是遵循某种奇怪的算法。第 $i$ 种牌被赋予一个权重 $X_i$ ($0 < X_i \le 1$)。在每一轮中,下一张抽到的牌是第 $i$ 种牌的概率为 $c_i X_i / S$,其中 $c_i$ 是剩余的第 $i$ 种牌的数量,$S = \sum_j c_j X_j$ 是所有剩余牌的权重之和。

为了准备下一场游戏,你希望能够预测发牌员的行为。幸运的是,你记得所有 100 000 局游戏中牌被抽出的顺序。给定这些信息,请找出赋予每种牌的权重。

输入格式

第一行包含两个整数 $m$ 和 $n$ ($m = 100\,000, 1 \le n \le 30$),分别表示游戏局数和牌的类型数量。

下一行包含 $n$ 个整数 $a_1, \dots, a_n$ ($1 \le a_i \le 2, \sum_{i=1}^n a_i = 30$),表示牌堆中第 $i$ 种牌的数量。

接下来的 $m$ 行,每行包含单局游戏的记录。记录由 30 个数字组成:按抽出顺序排列的牌的类型。对于每个 $1 \le i \le n$,数字 $i$ 在记录中恰好出现 $a_i$ 次。

输出格式

输出 $n$ 个数字 $W_1, \dots, W_n$ ($10^{-300} < W_i \le 1$),即预测的牌的权重。如果对于每一对类型 $i$ 和 $j$(满足 $X_i \le X_j$),满足以下条件,则答案被视为正确:

$$\left| \frac{X_i}{X_i + X_j} - \frac{W_i}{W_i + W_j} \right| < 0.02$$

样例

输入格式 1

4 3
2 1 1
1 1 2 3
1 2 1 3
1 2 3 1
2 1 1 3

输出格式 1

0.5 1.0 1.0

说明

小规模输入示例(注意:这不会出现在测试集中,因为 $m$ 总是 100 000):

4 3
2 1 1
1 1 2 3
1 2 1 3
1 2 3 1
2 1 1 3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#521Editorial Open集训队作业 解题报告 by 刘家炜Qingyu2026-01-02 21:39:07 Download
#108EditorialOpen题解Kevin53072025-12-12 19:50:04View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.