当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2765:Declaration of Content

题目描述
Most food you can buy at your local grocery store has a declaration of content. The declaration of content lists the ingredients of the product. It does not necessarily tell you the exact amount of every ingredient, only the ordering of the ingredients, from most common to least common. For some ingredients, an exact percentage might be given, either required by law or because the producer wants you to know how much of the fine expensive ingredients they have used. Given a set of different products and their respective declarations of content you should determine which contain the most or the least of some given ingredients. For simplicity, we assume in this problem that the percentage of each ingredient always is an integer.
输入解释
The input consists of several test cases. Each test case consists of two parts.

The first part of a test case begins with an integer P, 1 ≤ P ≤ 10, the number of different products in this test case, on a line of its own. Then follows the description of the P products. Each product description consists of a line giving the name of the product, followed by a line containing an integer n, 1 ≤ n ≤ 100, giving the number of ingredients in this product. Then follow n lines, the i:th of which contains the name of the i:th most common ingredient of the product. In case of ties, the ingredients will be listed in arbitrary order. Optionally, every ingredient name can be followed by space, an integer p, 0 ≤ p ≤ 100 and a percentage sign. If this is present, it specifies the exact amount of this ingredient in the product. Otherwise, because all percentages in this problem are integers, the ingredient makes up at least one percent of the total product.

The second part of a test case begins with an integer Q, 1 ≤ Q ≤ 100, the number of queries. Then follow Q lines, each containing a query. A query is of the form "least X", or "most X", where X is the name of an ingredient. In the "most X" case, the ingredient X is guaranteed to be present in at least one of the products.

A name of a product or an ingredient is a string of alphabetic characters (A-Z and a-z), digits (0-9) and underscore. Case is significant. No name will be longer than 30 characters. You may assume that each declaration of content is valid.

The last test case to be processed is followed by a line consisting of the integer 0.
输出解释
The output consists of one line for every query in the input data. For each query, output the name of the product containing the most or the least of ingredient X, as indicated by the query. If there are several possible such products, output all of them, in the same order as the products were presented in the test case input data. The product names should be separated by a single space.
输入样例
3
Product_1
3
A
B
C
Product_2
3
C
B
A
Product_3
2
B
C 35%
4
most A
most B
most C
least D
0
输出样例
Product_1
Product_3
Product_2 Product_3
Product_1 Product_2 Product_3

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2765

最后修改于 2020-10-29T06:42:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536