-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0cf.cpp
57 lines (45 loc) · 1.18 KB
/
0cf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t; cin >> t;
ll mod = 1e9+7;
while(t--){
ll n; cin >> n;
bool found = false;
bool rl = false;
vector<ll> arr[n+1];
set<ll> hi;
for(ll i = 0; i < n; i++){
ll k; cin >> k;
found = true;
for(ll j = 0; j < k; j++){
ll temp; cin >> temp;
arr[i].push_back(temp);
}
}
for(ll i = 0; i < n; i++){
found = true;
for(auto x: arr[i]){
if(i!=0 && hi.find(x) == hi.end()) found = false;
}
for(auto x: arr[i]){
hi.insert(x);
}
if(found && i!=0) rl = true;
}
hi.clear();
for(ll i = n-1; i >= 0; i--){
found = true;
for(auto x: arr[i]){
if(i!=(n-1) && hi.find(x) == hi.end()) found = false;
}
for(auto x: arr[i]){
hi.insert(x);
}
if(found && i!=(n-1)) rl = true;
}
if(rl) cout << "Yes\n";
else cout << "No\n";
}
}