#abc272b. B - Everyone is Friends

B - Everyone is Friends

Score : 200200 points

问题描述

NN 名编号为 1,2,,N1,2,\ldots,N 的人。

共举行了 MM 场聚会。在第 ii(1iM)(1\leq i \leq M) 聚会中,有 kik_i 人参加,他们是编号为 xi,1,xi,2,,xi,kix_{i,1},x_{i,2},\ldots,x_{i,k_i} 的人。

确定是否每两个人至少都曾参加过同一场聚会。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN people numbered 1,2,,N1,2,\ldots,N.

MM parties were held. kik_i people attended the ii-th (1iM)(1\leq i \leq M) party, and they were People xi,1,xi,2,,xi,kix_{i,1},x_{i,2},\ldots,x_{i,k_i}.

Determine if every two people attended the same party at least once.

Constraints

  • 2N1002\leq N \leq 100
  • 1M1001\leq M \leq 100
  • 2kiN2\leq k_i \leq N
  • 1xi,1<xi,2<<xi,kiN1\leq x_{i,1}<x_{i,2}<\ldots < x_{i,k_i}\leq N
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM

k1k_1 x1,1x_{1,1} x1,2x_{1,2} \ldots x1,k1x_{1,k_1}

\vdots

kMk_M xM,1x_{M,1} xM,2x_{M,2} \ldots xM,kMx_{M,k_M}

Output

Print Yes if every two people attended the same party at least once; print No otherwise.

Sample Input 1

3 3
2 1 2
2 2 3
2 1 3

Sample Output 1

Yes

Both Person 11 and Person 22 attended the 11-st party.

Both Person 22 and Person 33 attended the 22-nd party.

Both Person 11 and Person 33 attended the 33-rd party.

Therefore, every two people attended the same party at least once, so the answer is Yes.

Sample Input 2

4 2
3 1 2 4
3 2 3 4

Sample Output 2

No

Person 11 and Person 33 did not attend the same party, so the answer is No.

update @ 2024/3/10 11:27:29