#C4591. Merchant Fulfillment
Merchant Fulfillment
Merchant Fulfillment
In this problem, you are given a list of merchants, each with a set of items for sale. Each item is characterized by its name, price, and a list of properties. Additionally, you are given a list of customer requests. Each request specifies a set of required properties and a maximum price.
A merchant can fulfill a customer request if the merchant has at least one item such that its price satisfies the inequality $$price \leq max\_price$$ and its properties include all of the required properties (i.e. $$properties \supseteq required\_properties$$). The goal is to determine whether there is any single merchant who can fulfill all of the customer requests.
inputFormat
The input is read from standard input and consists of the following format:
- An integer M, representing the number of merchants.
- For each merchant:
- An integer N, representing the number of items for the merchant.
- A string representing the merchant's name.
- N lines, each line describes an item in the following format:
item_name item_price property1 property2 ...
- An integer K, representing the number of customer requests.
- K lines where each line describes a request in the following format:
property1 property2 ... max_price
All tokens are separated by whitespace.
outputFormat
Output to standard output a single line containing either Yes
if there exists a merchant who can fulfill all the customer requests, or No
if no such merchant exists.
2
2
Alice
ring 100 gold shiny
necklace 150 gold elegant
3
Bob
bracelet 200 silver elegant
earrings 50 gold shiny
watch 300 silver durable
2
gold shiny 120
silver elegant 250
Yes