CF234D.Cinema
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
Berland 总共有 m 位演员。每位演员有一个唯一的个人标识符——一个从 1 到 m 的整数(不同演员的标识符互不相同)。Vasya 喜欢观看由 Berland 演员出演的 Berland 电影,他有 k 位最喜爱的演员。他观看了下个月所有电影的预告片,并为每部电影记录了以下信息:电影标题、参演演员人数,以及这些演员的标识符。此外,他成功抄录了所有电影的标题及参演演员人数,但未能记下其中某些演员的标识符。Vasya 查看自己的记录,思考哪些电影可能成为他最喜爱的电影,哪些不可能成为他最喜爱的电影。一旦 Vasya 知晓所有电影的确切演员阵容,他的最喜爱电影将按如下规则确定:一部电影成为最喜爱电影,当且仅当在 Vasya 的电影列表中,没有任何其他电影所包含的最喜爱演员数量多于该电影。
请帮助这位少年对每部电影判断以下三种情况之一:
- 该电影必定会成为他最喜爱的电影;
- 该电影必定不会成为他最喜爱的电影;
- 该电影可能成为最喜爱电影,也可能不是。
输入格式
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.
输入的第一行包含两个整数 m 和 k(1 ≤ m ≤ 100,1 ≤ k ≤ m)—— 分别表示 Berland 国的演员总数以及 Vasya 最喜欢的演员人数。
第二行包含 k 个互不相同的整数 ai(1 ≤ ai ≤ m)—— 表示 Vasya 最喜欢的演员的编号。
第三行包含一个整数 n(1 ≤ n ≤ 100)—— 表示 Vasya 列表中电影的数量。
接下来是 n 个电影描述块,每个块对应一部电影。第 i 部电影的描述包含三行:
- 第一行是一个字符串 si(si 仅由小写英文字母组成,长度为 1 至 10 个字符,含端点)—— 该电影的片名;
- 第二行是一个非负整数 di(1 ≤ di ≤ m)—— 表示出演该电影的演员人数;
- 第三行包含 di 个整数 bi,j(0 ≤ bi,j ≤ m)—— 表示出演该电影的演员编号。若 bi,j=0,则表示 Vasya 不记得第 j 位演员的编号。保证每部电影的演员列表中不包含重复的演员。
所有电影的片名互不相同。同一行中的数字以单个空格分隔。
输出格式
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.
输出 n 行。在第 i 行中输出:
- 0,如果第 i 部电影必定是 favourite;
- 1,如果第 i 部电影必定不是 favourite;
- 2,如果第 i 部电影可能是 favourite,也可能不是 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.
第二个样例的说明:
- 电影《勇敢者游戏》理论上可以包含 1 到 3 名 Vasya 最喜欢的演员。
- 电影《鹰眼》包含了全部三名最喜欢的演员;Vasya 忘记了其中一名演员的名字,该演员的编号只能是 5。
- 电影《黑客帝国》恰好包含一名最喜欢的演员。
- 电影《源代码》不包含任何最喜欢的演员。
因此,电影《鹰眼》必定是 Vasya 喜欢的电影;电影《黑客帝国》和《源代码》必定不是 Vasya 喜欢的电影;而电影《勇敢者游戏》可能是(若它恰好包含全部三名最喜欢的演员)、也可能不是 Vasya 喜欢的电影。
输入解题思路,AI测评打分。不知道怎么写?