#C3930. Taco Ingredient Combination
Taco Ingredient Combination
Taco Ingredient Combination
In this problem, you are given (n) ingredients and (m) pairs representing incompatible ingredients. Two ingredients (u) and (v) are incompatible if they cannot be used together. You will be given (q) queries, each specifying a subset of ingredients. For each query, determine whether the selected ingredients can be combined without including any pair of incompatible ingredients. If the subset contains no incompatible pairs, output (YES); otherwise, output (NO).
inputFormat
The input is given through standard input with the following format:
- The first line contains two integers (n) and (m), representing the number of ingredients and the number of incompatible pairs, respectively.
- The next (m) lines each contain two integers (u) and (v) that describe an incompatible pair of ingredients.
- The following line contains an integer (q), denoting the number of queries.
- Each of the next (q) lines begins with an integer (k) (the number of ingredients in the query) followed by (k) space-separated integers representing the ingredients in the subset.
outputFormat
For each query, print a single line containing (YES) if the queried subset has no incompatible pairs, and (NO) otherwise.## sample
5 3
1 2
2 3
4 5
3
3 1 3 4
2 2 5
4 1 2 3 4
YES
YES
NO
</p>