#P1328. Dominant Set
Dominant Set
Dominant Set
题目描述
In graph theory, a dominant set for an undirected graph is a subset of such that every vertex not in is adjacent to at least one member of . Finding the minimum dominant set is an NP-hard problem. Your job is to verify, for a given graph, if a subset of vertices is a dominant set.
输入格式
Each input file contains one test case. For each case, the first line contains positive integers: , the number of vertices; and , the number of edges. Then lines follow, each gives indices of the two ends of an edge. The vertices are indexed from to . Then a positive integer is given, followed by lines of vertex sets. Each set is given in the format:
k v[1] v[2] ... v[k]
where is the number of vertices in the set, and it is followed by distinct indices of vertices.
输出格式
For each given set, print in a line yes if it is a dominant set, or no if not.
样例 #1
样例输入 #1
8 9
1 2
2 3
3 4
4 5
5 6
5 7
6 7
6 1
3 6
4
4 1 3 5 8
5 8 7 6 4 2
5 1 2 3 4 5
8 8 7 6 5 4 3 2 1
样例输出 #1
yes
yes
no
yes