#P3313. [Usaco2013 Nov]Farmer John has no Large Brown Cow
[Usaco2013 Nov]Farmer John has no Large Brown Cow
题目描述
农夫约翰喜欢收集各种奶牛。他用一串形容词描述一种奶牛,并记下了自己没有的 种奶牛。列表中的每句话含有相同数量的形容词。
每个位置可用的词,是该位置在列表中出现过的形容词。各位置各选一个词即可组成一种奶牛。除列表中明示没有的种类外,农夫约翰拥有其余所有种类。将已有奶牛的形容词序列按字典序排列,求第 种。
例如,若三个位置分别有 个不同词,则共有 种组合。样例列出其中三种作为缺项,农夫约翰拥有剩下的九种。
输入格式
从标准输入读取。第一行是两个整数 。接下来 行,每行是一个句子。句子由固定开头 Farmer John has no、中间的形容词序列和结尾 cow. 组成。
输出格式
向标准输出写入。输出一行,依次给出所求奶牛的形容词,相邻形容词之间用空格分隔。
样例 1
3 7
Farmer John has no large brown noisy cow.
Farmer John has no small white silent cow.
Farmer John has no large spotted noisy cow.
small spotted noisy
样例说明
九种已拥有的奶牛按字典序如下。
large brown silent
large spotted silent
large white noisy
large white silent
small brown noisy
small brown silent
small spotted noisy
small spotted silent
small white noisy
数据范围
,每行含 至 个形容词,每个形容词由至多 个英文小写字母组成。农夫约翰拥有的奶牛种类不超过 , 是其中一个从 开始的有效排名。
原赛十组测试中,第 至 组每行最多两个形容词,第 至 组每个位置恰有两个不同的词。