-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdishlife.cpp
84 lines (71 loc) · 1.94 KB
/
dishlife.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<bits/stdc++.h>
#define MAX 1000000
#define ll long long
#define DEBUG(x) do { std::cout << #x << ": " << x << " "; } while (0)
using namespace std;
int main()
{
int t,n,m,i,j,p,k;
int all,some,bad,flag,x,temp,island_required;
//bool a[MAX];//,island[MAX];
set <int> island,a;
set <int> :: iterator itr;
cin>>t;
while(t--){
cin>>n>>k;
//memset(a,0,sizeof(a));
some=0;
all=0;
a.clear();
for(i=0;i<n;++i)
{
cin>>p;
island.clear();
for(j=0;j<p;++j){
cin>>temp;
island.insert(temp);
}
x=1;
/*for(itr=island.begin();itr!=island.end(); ++itr){
cout<<*itr;
}
cout<<endl;*/
for(itr=a.begin();itr!=a.end();++itr){
//DEBUG(j);DEBUG(a[j]);
if (island.find(*itr)==island.end())
{
x=0; //a is not subset of new island
}
}
//cout<<endl;
if(i>=1 && x==1){
some=1;
}
//DEBUG(some);
island_required=0;
for(itr=island.begin();itr!=island.end(); ++itr){
if(*itr <=k && a.find(*itr)==a.end()) //island is not subset of a
{
island_required=1;
a.insert(*itr);
}
}
if(island_required==0) //redundant island
some=1;
//DEBUG(some);
}
flag=1;
for(i=1;i<=k;++i){
if(a.find(i)==a.end())
flag=0;
}
if(flag==0)
cout<<"sad\n";
else if(some==1){
cout<<"some\n";
}
else
cout<<"all\n";
}
return 0;
}