(怎么感觉分多的题老是map小声BB)
#pragma GCC optimize(2) #include <cstdio> #include <cstring> #include <algorithm> #include <set> #include<iostream> #include<vector> #include<queue> #include<map> #include<stack> #include<iomanip> #include<bits/stdc++.h> using namespace std; typedef long long ll; #define SIS std::ios::sync_with_stdio(false) #define space putchar(' ') #define enter putchar('\n') #define lson root<<1 #define rson root<<1|1 typedef pair<int,int> PII; const int mod=1000000007 ; const int N=2e6+10; const int M=1e3+10; const int inf=0x7f7f7f7f; const int maxx=2e5+7; const double eps=1e-6; ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } ll lcm(ll a,ll b) { return a*(b/gcd(a,b)); } template <class T> void read(T &x) { char c; bool op = 0; while(c = getchar(), c < '0' || c > '9') if(c == '-') op = 1; x = c - '0'; while(c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0'; if(op) x = -x; } template <class T> void write(T x) { if(x < 0) x = -x, putchar('-'); if(x >= 10) write(x / 10); putchar('0' + x % 10); } ll qsm(int a,int b,int p) { ll res=1%p; while(b) { if(b&1) res=res*a%p; a=1ll*a*a%p; b>>=1; } return res; } map<int,vector<int> >mp; int main() { int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { int x,y; scanf("%d%d",&x,&y); mp[x].push_back(y); } while(m--) { int len; vector<int> vt; scanf("%d",&len); map<int,int> check; for(int i=0;i<len;i++) { int x; scanf("%d",&x); check[x]++; vt.push_back(x); } int flag=0; for(int i=0;i<vt.size();i++) { for(int j=0;j<mp[vt[i]].size();j++) { if(check[mp[vt[i]][j]]){ printf("No\n");flag=1;break; } } if(flag)break; } if(!flag)printf("Yes\n"); } return 0; }