QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#14506. 木林森

Statistics

小 W 喜歡樹。這天她在夢裡構造了一棵 $n$ 個結點的樹,並選取了這棵樹的 $m$ 個連通塊記錄下來。然而當她從夢裡醒來時,卻發現自己忘掉了夢裡的樹的結構,連通塊的資訊也記不太清了,能確定的是這些連通塊的大小都不超過 $k$。她憑記憶在紙上寫下了這 $m$ 個連通塊對應的點集,你能告訴她是否存在一棵樹使得這 $m$ 個點集確實都是這棵樹的一個連通塊嗎?

輸入格式

第一行三個正整數 $n, m, k$ ($1 \le n, m \le 10^4, 2 \le k \le 20$)。依次表示原樹的大小,點集的個數,點集大小的上界。

接下來 $m$ 行,每行包含若干正整數,第一個正整數為 $s_i$ ($2 \le s_i \le k$),表示對應點集的大小,後面緊跟 $s_i$ 個互不相同的正整數,表示這個點集的元素。

輸出格式

一行一個字串。如果答案為存在,請輸出 YES。否則輸出 NO(不區分大小寫)。

範例

範例輸入 1

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

範例輸出 1

YES

範例輸入 2

6 4 3
3 1 2 3
3 3 4 5
2 5 6
2 6 1

範例輸出 2

NO

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.