301250: CF234D. Cinema

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

Description

Cinema

题意翻译

有 $m$ 个演员编号分别为 $1$ 至 $m$。其中,编号分别为 $a_1$ 至 $a_k$ 的 $k$ 个演员是小 V 所喜爱的。 当且仅当不存在拥有更多小 V 喜欢的演员的电影时,这个一个电影是小 V 喜爱的的电影。 小 V 记录了下个月 $n$ 个电影的影片名称 $s_i$,演员人数 $d_i$ 和演员编号 $b_{ij}$。特殊地,若给定的演员编号为 $0$ 则代表小 V 忘记了这个演员的编号。 试求出每个电影是否是小 V 喜爱的电影。若肯定是,输出 ``0``;若不可能是,输出``1``,若不确定,输出``2``。 $1\leq k \leq m \leq 100$,$1\leq d_i\leq m$,$0\leq b_{ij}\leq m$,$1\leq |s_i|\leq10$。 电影名称由小写字母组成。同一部电影中不会出现两个相同的演员编号。 文件输入输出。输入输出文件分别是 ``input.txt`` 以及 ``output.txt``。 由于 Codeforces 系统更新后本题数据没有更新,本题用时将会被乘 $2$ 。例如:400 ms 的代码将被视为 800 ms。

题目描述

Overall there are $ m $ actors in Berland. Each actor has a personal identifier — an integer from $ 1 $ to $ m $ (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has $ k $ favorite actors. He watched the movie trailers for the next month and wrote the following information for every movie: the movie title, the number of actors who starred in it, and the identifiers of these actors. Besides, he managed to copy the movie titles and how many actors starred there, but he didn't manage to write down the identifiers of some actors. Vasya looks at his records and wonders which movies may be his favourite, and which ones may not be. Once Vasya learns the exact cast of all movies, his favorite movies will be determined as follows: a movie becomes favorite movie, if no other movie from Vasya's list has more favorite actors. Help the boy to determine the following for each movie: - whether it surely will be his favourite movie; - whether it surely won't be his favourite movie; - can either be favourite or not.

输入输出格式

输入格式


The first line of the input contains two integers $ m $ and $ k $ ( $ 1<=m<=100,1<=k<=m $ ) — the number of actors in Berland and the number of Vasya's favourite actors. The second line contains $ k $ distinct integers $ a_{i} $ ( $ 1<=a_{i}<=m $ ) — the identifiers of Vasya's favourite actors. The third line contains a single integer $ n $ ( $ 1<=n<=100 $ ) — the number of movies in Vasya's list. Then follow $ n $ blocks of lines, each block contains a movie's description. The $ i $ -th movie's description contains three lines: - the first line contains string $ s_{i} $ ( $ s_{i} $ consists of lowercase English letters and can have the length of from $ 1 $ to $ 10 $ characters, inclusive) — the movie's title, - the second line contains a non-negative integer $ d_{i} $ ( $ 1<=d_{i}<=m $ ) — the number of actors who starred in this movie, - the third line has $ d_{i} $ integers $ b_{i,j} $ ( $ 0<=b_{i,j}<=m $ ) — the identifiers of the actors who star in this movie. If $ b_{i,j}=0 $ , than Vasya doesn't remember the identifier of the $ j $ -th actor. It is guaranteed that the list of actors for a movie doesn't contain the same actors. All movies have distinct names. The numbers on the lines are separated by single spaces.

输出格式


Print $ n $ lines in the output. In the $ i $ -th line print: - 0, if the $ i $ -th movie will surely be the favourite; - 1, if the $ i $ -th movie won't surely be the favourite; - 2, if the $ i $ -th movie can either be favourite, or not favourite.

输入输出样例

输入样例 #1

5 3
1 2 3
6
firstfilm
3
0 0 0
secondfilm
4
0 0 4 5
thirdfilm
1
2
fourthfilm
1
5
fifthfilm
1
4
sixthfilm
2
1 0

输出样例 #1

2
2
1
1
1
2

输入样例 #2

5 3
1 3 5
4
jumanji
3
0 0 0
theeagle
5
1 2 3 4 0
matrix
3
2 4 0
sourcecode
2
2 4

输出样例 #2

2
0
1
1

说明

Note to the second sample: - Movie jumanji can theoretically have from 1 to 3 Vasya's favourite actors. - Movie theeagle has all three favourite actors, as the actor Vasya failed to remember, can only have identifier 5. - Movie matrix can have exactly one favourite actor. - Movie sourcecode doesn't have any favourite actors. Thus, movie theeagle will surely be favourite, movies matrix and sourcecode won't surely be favourite, and movie jumanji can be either favourite (if it has all three favourite actors), or not favourite.

Input

题意翻译

有 $m$ 个演员编号分别为 $1$ 至 $m$。其中,编号分别为 $a_1$ 至 $a_k$ 的 $k$ 个演员是小 V 所喜爱的。 当且仅当不存在拥有更多小 V 喜欢的演员的电影时,这个一个电影是小 V 喜爱的的电影。 小 V 记录了下个月 $n$ 个电影的影片名称 $s_i$,演员人数 $d_i$ 和演员编号 $b_{ij}$。特殊地,若给定的演员编号为 $0$ 则代表小 V 忘记了这个演员的编号。 试求出每个电影是否是小 V 喜爱的电影。若肯定是,输出 ``0``;若不可能是,输出``1``,若不确定,输出``2``。 $1\leq k \leq m \leq 100$,$1\leq d_i\leq m$,$0\leq b_{ij}\leq m$,$1\leq |s_i|\leq10$。 电影名称由小写字母组成。同一部电影中不会出现两个相同的演员编号。 文件输入输出。输入输出文件分别是 ``input.txt`` 以及 ``output.txt``。 由于 Codeforces 系统更新后本题数据没有更新,本题用时将会被乘 $2$ 。例如:400 ms 的代码将被视为 800 ms。

加入题单

算法标签: