我的个人网站 Cheese的个人主页http://www.cheese.ren/
博客来源 PAT 乙级 1090 危险品装箱-Cheese的个人博客PAT 乙级 1090 危险品装箱 C++http://blog.cheese.ren/110
欢迎交换友链 :-)
#include <bits/stdc++.h>
using namespace std;
struct BadGoods
{
int a, b;
bool is_ok=false;
};
int main() {
map<int, vector<int>> _map;
int n, m;
cin >> n >> m;
while (n--) {
int a, b;
cin >> a >> b;
_map[a].push_back(b);
_map[b].push_back(a);
}
while (m--) {
bool goods[100000]={false};
int num;
cin >> num;
vector<int> _vec(num);
for (int i=0; i<num; i++) {
cin >> _vec[i];
goods[_vec[i]] = true;
}
bool flag=true;
for (int i=0; i<_vec.size(); i++) {
for (int l=0; l<_map[_vec[i]].size(); l++) {
if (goods[_map[_vec[i]][l]])
flag = false;
}
}
printf("%s\n", flag ? "Yes":"No");
}
return 0;
}