AcWing 1642. 危险品装箱
原题链接
简单
作者:
sy123
,
2020-10-23 17:21:58
,
所有人可见
,
阅读 577
#include <iostream>
#include <unordered_set>
using namespace std;
const int N = 10010;
int n, m;
int a[N], b[N];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i ++ ) scanf("%d%d", &a[i], &b[i]);
while (m -- )
{
int k;
scanf("%d", &k);
unordered_set<int> S;
while (k -- )
{
int x;
scanf("%d", &x);
S.insert(x);
}
bool success = true;
for (int i = 0; i < n; i ++ )
if (S.count(a[i]) && S.count(b[i]))
{
success = false;
break;
}
if (success) puts("Yes");
else puts("No");
}
return 0;
}
666