QOJ.ac

QOJ

时间限制: 1 s 内存限制: 2048 MB 总分: 100

#1946. 调查冒名顶替者

统计

你偶然发现了一个村庄。在这个村庄里,有些人是“冒名顶替者”(imposters),而其余的人则不是。幸运的是,你知道冒名顶替者的数量是有限的!

你想要确定村里谁不是冒名顶替者。为此,你要求每位村民提交一份他们认为不是冒名顶替者的名单。

非冒名顶替者只会提交包含其他非冒名顶替者名字的名单,而冒名顶替者则没有这种限制。冒名顶替者的名单中可能包含冒名顶替者,也可能包含非冒名顶替者。

给定每位村民的名单,请确定他们是否可能是冒名顶替者,或者确定他们绝对不是冒名顶替者。

输入格式

第一行包含两个空格分隔的整数 $n$ 和 $k$ ($1 \le k \le n \le 500$),其中 $n$ 是村民人数,$k$ 是冒名顶替者的最大可能数量。村民编号为 $1$ 到 $n$。

接下来的 $n$ 行描述了每位村民的信息,第 $i$ 行代表村民 $i$ 的名单。第 $i$ 行以一个整数 $s$ ($0 \le s \le n$) 开头,表示村民 $i$ 名单中认为不是冒名顶替者的人数。随后是 $s$ 个不同的整数,表示村民 $i$ 名单中认为不是冒名顶替者的村民编号。村民可能出现在自己的名单中。任何给定名单中的村民编号都是唯一的。

输出格式

输出 $n$ 行,每行包含一个整数。如果输入中第 $i$ 个列表所代表的村民可能是冒名顶替者,则第 $i$ 行应输出 $0$;如果该村民绝对不是冒名顶替者,则输出 $1$。

样例

输入 1

4 1
1 2
1 1
1 3
1 4

输出 1

1
1
0
0

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.