QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#22650. 探險隊

الإحصائيات

乳牛想組建探險隊,探索 Farmer John 領地邊緣的樹林。探險需要比站在牧場吃草更多的技能。

這些編號為 1..$C$ 的 $C$ 頭乳牛($1 \le C \le 20$)組成的隊伍,需要有乳牛能在樹林中辨路而不迷路、抵禦凶惡的大型生物、講笑話鼓舞士氣等等。對於編號 1..$A$ 的 $A$ 種特殊能力($1 \le A \le 20$),隊伍中必須至少有一頭乳牛擁有每種能力。一些乳牛只會一種,很多會多種,也有完全沒用的混飯者。

給定所有乳牛及其能力,計算能組建多少支不同的探險隊,使隊伍整體擁有所有給定能力。

輸入格式

  • 第 1 行:兩個整數 $C$ 和 $A$。
  • 第 2..$A$+1 行:每行用一組空格分隔的整數描述一種能力。第 2 行描述能力 1,第 3 行描述能力 2,依此類推。每行第一個整數 $K$($1 \le K \le C$)是擁有該能力的乳牛數。隨後 $K$ 個整數表示擁有該能力的乳牛。

輸出格式

  • 第 1 行:一個整數,表示能組建的不同探險隊數。

範例

輸入格式 1

4 2
2 3 1
1 2

輸出格式 1

6

說明

輸入詳情

有 4 頭乳牛和 2 種能力。乳牛 1、3 擁有能力 1,僅乳牛 2 擁有能力 2。乳牛 4 比較沒有才能。

輸出詳情

可能的探險隊為:$\{1, 2\}$、$\{2, 3\}$、$\{1, 2, 3\}$、$\{1, 2, 4\}$、$\{2, 3, 4\}$ 和 $\{1, 2, 3, 4\}$。

題目作者:Percy Liang,2004

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.