QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#14506. 木林森

統計

小 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.