102721: [AtCoder]ABC272 B - Everyone is Friends

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

There are $N$ people numbered $1,2,\ldots,N$.

$M$ parties were held. $k_i$ people attended the $i$-th $(1\leq i \leq M)$ party, and they were People $x_{i,1},x_{i,2},\ldots,x_{i,k_i}$.

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

Constraints

  • $2\leq N \leq 100$
  • $1\leq M \leq 100$
  • $2\leq k_i \leq N$
  • $1\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:

$N$ $M$
$k_1$ $x_{1,1}$ $x_{1,2}$ $\ldots$ $x_{1,k_1}$
$\vdots$
$k_M$ $x_{M,1}$ $x_{M,2}$ $\ldots$ $x_{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 $1$ and Person $2$ attended the $1$-st party.

Both Person $2$ and Person $3$ attended the $2$-nd party.

Both Person $1$ and Person $3$ attended the $3$-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 $1$ and Person $3$ did not attend the same party, so the answer is No.

Input

题意翻译

## 题目描述 有 $N$ 个编号为 $1,2,\ldots,N$ 的人。 现在有 $M$ 场排队。第 $i(1 \le i \leq M)$ 场排队有 $k_i$ 个人参加,编号为 $ x_{i,1},x_{i,2},\ldots,x_{i,k_i} $。 现在要求你判断是否存在任意两个人都参加过同一场派对。 ## 输入格式 输入按照以下格式 > $ N $ $ M $ > $ k_1 \ x_{1,1} \ x_{1,2} \ \ldots \ x_{1,k_1} $ > $\vdots $ > $ k_M \ x_{M,1} \ x_{M,2}\ \ldots \ x_{M,k_M} $ ## 输出格式 `Yes` 或 `No`。 ## 数据规模 - $ 2\le N \le 100 , 1\le M \le 100 ,2\le k_i \le N $ - $ 1\le x_{i,1} <\ x_{i,2}\ <\ \ldots\ <\ x_{i,k_i}\leq\ N $ - 保证输入均为整数 ## 样例 1 解释 $1$ 和 $2$ 都参加了第 $1$ 场排队。 $2$ 和 $3$ 都参加了第 $2$ 场排队。 $1$ 和 $3$ 都参加了第 $3$ 场排队。

Output

得分:200分 部分 问题描述 有N个编号为1,2,…,N的人。 举行了M个派对。第i个派对(1≤i≤M)有k_i人参加,他们是People x_{i,1},x_{i,2},…,x_{i,k_i}。 确定是否每两个人都至少参加过一次相同的派对。 部分 约束条件 * 2≤N≤100 * 1≤M≤100 * 2≤k_i≤N * 1≤x_{i,1}<x_{i,2}<…<x_{i,k_i}≤N * 输入中的所有值都是整数。 输入输出格式 输入 输入以以下格式从标准输入给出: N M k_1 x_{1,1} x_{1,2} … x_{1,k_1} vdots k_M x_{M,1} x_{M,2} … x_{M,k_M} 输出 如果每两个人都至少参加过一次相同的派对,则打印Yes;否则打印No。 样例输入1 3 3 2 1 2 2 2 3 2 1 3 样例输出1 Yes 第1个人和第2个人参加了第1个派对。 第2个人和第3个人参加了第2个派对。 第1个人和第3个人参加了第3个派对。 因此,每两个人都至少参加过一次相同的派对,所以答案是Yes。 样例输入2 4 2 3 1 2 4 3 2 3 4 样例输出2 No 第1个人和第3个人没有参加过相同的派对,所以答案是No。

加入题单

算法标签: