QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 1024 MB Points totaux : 100

#10677. 地铁测验

Statistiques

两位奥运会观众正在排队。她们每人手里都有一份巴黎地铁图,并想出了一个小游戏来打发时间。首先,玩家 A 在所有地铁线路中随机选择一条(等概率选择),玩家 B 需要猜出这条线路。为了猜出线路,玩家 B 反复询问该线路是否停靠在某个她选择的地铁站,玩家 A 会如实回答。在经过足够多次的询问后,玩家 B 通常能确定玩家 A 心中想的是哪条地铁线路。当然,玩家 B 希望最小化她需要询问的问题数量。

给定 $M$ 条地铁线路(编号从 $1$ 到 $M$)的地图,共有 $N$ 个地铁站(编号从 $0$ 到 $N-1$),并指明了每条线路停靠的站点。请计算在最优策略下,玩家 B 为了找到答案所需询问问题的期望数量。

换句话说,给定一种策略 $S$,记 $Q_{S,j}$ 为如果目标线路是第 $j$ 条线路时,该策略所询问的问题数量。那么,记 $$E_S = \mathbb{E}[Q_S] = \frac{1}{M} \sum_{j=1}^{M} Q_{S,j}$$ 为假设 $j$ 在所有地铁线路集合中均匀随机选择时,$Q_{S,j}$ 的期望值。你的任务是计算 $\min_S E_S$。

如果玩家 B 无法总是确定玩家 A 心中想的是哪条线路,则输出 not possible

输入格式

第一行包含数字 $N$。第二行包含数字 $M$。接下来 $M$ 行:第 $k$ 行首先包含一个正整数 $n \leqslant N$,随后是一个空格,接着是 $n$ 个空格分隔的整数 $s_1, s_2, \dots, s_n$,这些是第 $k$ 条线路停靠的地铁站。一条线路在给定的站点最多停靠一次。

输出格式

输出一行,包含一个数字:玩家 B 为了找到正确线路所需询问问题的最小期望数量,或者输出 not possible(小写字母)。与正确答案误差在 $10^{-4}$ 以内的答案将被接受。

数据范围

  • $1 \leqslant N \leqslant 18$
  • $1 \leqslant M \leqslant 50$

样例

样例输入 1

5
4
3 0 3 4
3 0 2 3
3 2 3 4
2 1 2

样例输出 1

2

样例输入 2

3
3
1 0
1 1
1 2

样例输出 2

1.66666666666667

说明 2

询问关于站点 0 的第一个问题:根据问题的对称性,这是最优的。这使我们能够区分停靠在站点 0 的线路 1,以及不停靠该站点的线路 2 和线路 3。如果需要,再问第二个问题以区分线路 2 和线路 3。 如果答案是线路 1,玩家 B 问一个问题;否则问两个问题。因此,她询问问题的期望数量为 $(1 + 2 \times 2)/3$。

巴黎地铁图

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.