#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const ll N = 100009;
ll mod = 1e9 + 7;
const ll maxn = 110;
bitset<1009> bit[10009];
inline ll rd() {
ll x = 0, f = 1;
char ch = getchar();
while (ch < ‘0‘ || ch > ‘9‘) {
if (ch == ‘-‘) f = -1;
ch = getchar();
}
while (ch >= ‘0‘ && ch <= ‘9‘) {
x = (x << 3) + (x << 1) + (ch ^ 48); //二进制向左移动三位+向左移动1位,x*2*2*2+x*2
//= x*10, ch^48 = ch‘0‘
ch = getchar();
}
return x * f;
}
void solve() {
ll n;
n = rd();
for (int i = 1; i <=n; i ++) {
ll cnt;
cnt = rd();
while (cnt--) {
ll x;
x = rd();
bit[x].set(i);
}
}
ll q;
q = rd();
while (q--) {
ll l, r;
l = rd();
r = rd();
bool f = 0;
bitset<1009> t;
t = bit[l] & bit[r];
if (!(t.any()))puts("No");
else puts("Yes");
}
}
signed main() {
ll t = 1;//cin >> t;
while (t--) solve();
return 0;
}
原文:https://www.cnblogs.com/Xiao-yan/p/14609824.html