#C5404. Filter Products Based on Characteristics

    ID: 49050 Type: Default 1000ms 256MiB

Filter Products Based on Characteristics

Filter Products Based on Characteristics

You are required to filter products based on specific category characteristics.

Given a list of products (each represented as a JSON object with an integer id field and additional attributes) and a set of category characteristics (provided as a JSON object where each key-value pair specifies an attribute and its required value), your task is to print the ids of all products that satisfy all the given characteristics.

For instance, if the criteria is {color: blue, brand: BrandA}\{\text{color: blue},\ \text{brand: BrandA}\}, then only products that are blue and belong to BrandA should be selected. If no product meets the criteria, output nothing.

inputFormat

The input is read from stdin and consists of two lines:
1. The first line is a JSON string representing an array of products. Each product is a JSON object with an integer field id and additional string attributes (for example, color, size, brand).
2. The second line is a JSON string representing a JSON object of category characteristics. Each key-value pair denotes an attribute and the required value.

Example:
[{"id": 101, "color": "blue", "size": "M", "brand": "BrandA"}, {"id": 102, "color": "red", "size": "L", "brand": "BrandB"}]
{"color": "blue", "brand": "BrandA"}

outputFormat

The output, written to stdout, consists of the ids of all products that meet all the category characteristics. The ids should be printed in the order they appear in the input, separated by a single space. If no product meets the criteria, print nothing.## sample

[{"id": 101, "color": "blue", "size": "M", "brand": "BrandA"}, {"id": 102, "color": "red", "size": "L", "brand": "BrandB"}, {"id": 103, "color": "blue", "size": "S", "brand": "BrandA"}, {"id": 104, "color": "green", "size": "M", "brand": "BrandC"}]
{"color": "blue", "brand": "BrandA"}
101 103