#include<bits/stdc++.h>
using namespace std;
#define maxn 50005
#define pii pair<int,int>
int n,k,deg[maxn],ans,len,num[maxn],res;
vector<int> edge[maxn],ver;
set<pii> s;
bool check[maxn];
bool ok(int mask){
for(int i=0;i<len;i++){
if(((mask>>i)&1)==0) continue;
for(int j=0;j<i;j++){
if(((mask>>j)&1)==0) continue;
int a=ver[i],b=ver[j];
if(*lower_bound(edge[a].begin(),edge[a].end(),b)!=b) return false;
}
}
return true;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n >> k;
for(int i=1;i<=n;i++){
cin >> deg[i];s.insert({deg[i],i});
for(int j=1;j<=deg[i];j++){
int x;cin >> x;x++;
edge[i].push_back(x);
}
sort(edge[i].begin(),edge[i].end());
}
for(int i=1;i<=n;i++){
pii p=*s.begin();check[p.second]=true;
s.erase(s.begin());ver={p.second};
for(int v:edge[p.second]){
if(check[v]) continue;
ver.push_back(v);
}
len=(int)ver.size();
for(int mask=(1<<len)-1;mask>=(1<<ans);mask--){
int cnt=0;
for(int j=0;j<len;j++) cnt+=(mask>>j)&1;
if(cnt<=ans) continue;
if(ok(mask)) ans=cnt;
}
for(int v:edge[p.second]){
if(check[v]) continue;
s.erase({deg[v],v});deg[v]--;
s.insert({deg[v],v});
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1876 KB |
Output is correct |
5 |
Correct |
4 ms |
1836 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
5 ms |
1876 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1876 KB |
Output is correct |
5 |
Correct |
4 ms |
1836 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
5 ms |
1876 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
1888 KB |
Output is correct |
12 |
Correct |
4 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
4 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
5 ms |
1956 KB |
Output is correct |
19 |
Correct |
2 ms |
1732 KB |
Output is correct |
20 |
Correct |
3 ms |
1876 KB |
Output is correct |
21 |
Correct |
3 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1748 KB |
Output is correct |
23 |
Correct |
5 ms |
1888 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
6 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1824 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
6 ms |
1876 KB |
Output is correct |
29 |
Correct |
5 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1888 KB |
Output is correct |
32 |
Correct |
5 ms |
1876 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1884 KB |
Output is correct |
35 |
Correct |
3 ms |
1620 KB |
Output is correct |
36 |
Correct |
3 ms |
1620 KB |
Output is correct |
37 |
Correct |
3 ms |
1620 KB |
Output is correct |
38 |
Correct |
3 ms |
1620 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
11 ms |
1876 KB |
Output is correct |
41 |
Correct |
2 ms |
1580 KB |
Output is correct |
42 |
Correct |
7 ms |
1932 KB |
Output is correct |
43 |
Correct |
7 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1748 KB |
Output is correct |
2 |
Correct |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
299 ms |
7984 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
394 ms |
7904 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
299 ms |
7988 KB |
Output is correct |
16 |
Correct |
314 ms |
7892 KB |
Output is correct |
17 |
Correct |
342 ms |
7932 KB |
Output is correct |
18 |
Correct |
295 ms |
7960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1876 KB |
Output is correct |
5 |
Correct |
4 ms |
1836 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
5 ms |
1876 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
1888 KB |
Output is correct |
12 |
Correct |
4 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
4 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
5 ms |
1956 KB |
Output is correct |
19 |
Correct |
2 ms |
1732 KB |
Output is correct |
20 |
Correct |
3 ms |
1876 KB |
Output is correct |
21 |
Correct |
3 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1748 KB |
Output is correct |
23 |
Correct |
5 ms |
1888 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
6 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1824 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
6 ms |
1876 KB |
Output is correct |
29 |
Correct |
5 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1888 KB |
Output is correct |
32 |
Correct |
5 ms |
1876 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1884 KB |
Output is correct |
35 |
Correct |
3 ms |
1620 KB |
Output is correct |
36 |
Correct |
3 ms |
1620 KB |
Output is correct |
37 |
Correct |
3 ms |
1620 KB |
Output is correct |
38 |
Correct |
3 ms |
1620 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
11 ms |
1876 KB |
Output is correct |
41 |
Correct |
2 ms |
1580 KB |
Output is correct |
42 |
Correct |
7 ms |
1932 KB |
Output is correct |
43 |
Correct |
7 ms |
1876 KB |
Output is correct |
44 |
Correct |
10 ms |
1924 KB |
Output is correct |
45 |
Correct |
2 ms |
1492 KB |
Output is correct |
46 |
Correct |
9 ms |
1952 KB |
Output is correct |
47 |
Correct |
19 ms |
2004 KB |
Output is correct |
48 |
Correct |
8 ms |
1876 KB |
Output is correct |
49 |
Correct |
20 ms |
2044 KB |
Output is correct |
50 |
Correct |
20 ms |
2052 KB |
Output is correct |
51 |
Correct |
119 ms |
2180 KB |
Output is correct |
52 |
Correct |
4 ms |
1876 KB |
Output is correct |
53 |
Correct |
297 ms |
2344 KB |
Output is correct |
54 |
Correct |
228 ms |
2324 KB |
Output is correct |
55 |
Correct |
4 ms |
1876 KB |
Output is correct |
56 |
Correct |
4 ms |
1876 KB |
Output is correct |
57 |
Correct |
2 ms |
1748 KB |
Output is correct |
58 |
Correct |
304 ms |
2348 KB |
Output is correct |
59 |
Correct |
6 ms |
1876 KB |
Output is correct |
60 |
Correct |
4 ms |
1876 KB |
Output is correct |
61 |
Correct |
5 ms |
1876 KB |
Output is correct |
62 |
Correct |
6 ms |
1876 KB |
Output is correct |
63 |
Correct |
10 ms |
1952 KB |
Output is correct |
64 |
Correct |
9 ms |
1876 KB |
Output is correct |
65 |
Correct |
6 ms |
1876 KB |
Output is correct |
66 |
Correct |
6 ms |
1876 KB |
Output is correct |
67 |
Correct |
23 ms |
2004 KB |
Output is correct |
68 |
Correct |
8 ms |
1876 KB |
Output is correct |
69 |
Correct |
7 ms |
1876 KB |
Output is correct |
70 |
Correct |
14 ms |
2004 KB |
Output is correct |
71 |
Correct |
25 ms |
2076 KB |
Output is correct |
72 |
Correct |
22 ms |
2092 KB |
Output is correct |
73 |
Correct |
5 ms |
1876 KB |
Output is correct |
74 |
Correct |
12 ms |
2036 KB |
Output is correct |
75 |
Correct |
23 ms |
2084 KB |
Output is correct |
76 |
Correct |
10 ms |
1924 KB |
Output is correct |
77 |
Correct |
61 ms |
2156 KB |
Output is correct |
78 |
Correct |
4 ms |
1876 KB |
Output is correct |
79 |
Correct |
29 ms |
1876 KB |
Output is correct |
80 |
Correct |
9 ms |
1876 KB |
Output is correct |
81 |
Correct |
69 ms |
2148 KB |
Output is correct |
82 |
Correct |
2 ms |
1620 KB |
Output is correct |
83 |
Correct |
33 ms |
1748 KB |
Output is correct |
84 |
Correct |
25 ms |
2252 KB |
Output is correct |
85 |
Correct |
2 ms |
1620 KB |
Output is correct |
86 |
Correct |
15 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1876 KB |
Output is correct |
5 |
Correct |
4 ms |
1836 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
5 ms |
1876 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
1888 KB |
Output is correct |
12 |
Correct |
4 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
4 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
5 ms |
1956 KB |
Output is correct |
19 |
Correct |
2 ms |
1732 KB |
Output is correct |
20 |
Correct |
3 ms |
1876 KB |
Output is correct |
21 |
Correct |
3 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1748 KB |
Output is correct |
23 |
Correct |
5 ms |
1888 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
6 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1824 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
6 ms |
1876 KB |
Output is correct |
29 |
Correct |
5 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1888 KB |
Output is correct |
32 |
Correct |
5 ms |
1876 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1884 KB |
Output is correct |
35 |
Correct |
3 ms |
1620 KB |
Output is correct |
36 |
Correct |
3 ms |
1620 KB |
Output is correct |
37 |
Correct |
3 ms |
1620 KB |
Output is correct |
38 |
Correct |
3 ms |
1620 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
11 ms |
1876 KB |
Output is correct |
41 |
Correct |
2 ms |
1580 KB |
Output is correct |
42 |
Correct |
7 ms |
1932 KB |
Output is correct |
43 |
Correct |
7 ms |
1876 KB |
Output is correct |
44 |
Correct |
1 ms |
1492 KB |
Output is correct |
45 |
Correct |
140 ms |
6412 KB |
Output is correct |
46 |
Correct |
67 ms |
5744 KB |
Output is correct |
47 |
Correct |
166 ms |
6360 KB |
Output is correct |
48 |
Correct |
147 ms |
6408 KB |
Output is correct |
49 |
Correct |
41 ms |
5748 KB |
Output is correct |
50 |
Correct |
164 ms |
6472 KB |
Output is correct |
51 |
Correct |
172 ms |
6440 KB |
Output is correct |
52 |
Correct |
41 ms |
5848 KB |
Output is correct |
53 |
Correct |
45 ms |
5832 KB |
Output is correct |
54 |
Correct |
13 ms |
4052 KB |
Output is correct |
55 |
Correct |
173 ms |
6716 KB |
Output is correct |
56 |
Correct |
28 ms |
5656 KB |
Output is correct |
57 |
Correct |
47 ms |
5840 KB |
Output is correct |
58 |
Correct |
51 ms |
5576 KB |
Output is correct |
59 |
Correct |
30 ms |
5588 KB |
Output is correct |
60 |
Correct |
32 ms |
5636 KB |
Output is correct |
61 |
Correct |
48 ms |
5640 KB |
Output is correct |
62 |
Correct |
39 ms |
5576 KB |
Output is correct |
63 |
Correct |
75 ms |
5836 KB |
Output is correct |
64 |
Correct |
30 ms |
5644 KB |
Output is correct |
65 |
Correct |
110 ms |
6072 KB |
Output is correct |
66 |
Correct |
39 ms |
5636 KB |
Output is correct |
67 |
Correct |
76 ms |
5780 KB |
Output is correct |
68 |
Correct |
93 ms |
5992 KB |
Output is correct |
69 |
Correct |
97 ms |
6148 KB |
Output is correct |
70 |
Correct |
46 ms |
5640 KB |
Output is correct |
71 |
Correct |
125 ms |
5964 KB |
Output is correct |
72 |
Correct |
65 ms |
5780 KB |
Output is correct |
73 |
Correct |
119 ms |
6140 KB |
Output is correct |
74 |
Correct |
43 ms |
5588 KB |
Output is correct |
75 |
Correct |
42 ms |
3668 KB |
Output is correct |
76 |
Correct |
71 ms |
5812 KB |
Output is correct |
77 |
Correct |
126 ms |
6132 KB |
Output is correct |
78 |
Correct |
55 ms |
3828 KB |
Output is correct |
79 |
Correct |
42 ms |
3668 KB |
Output is correct |
80 |
Correct |
18 ms |
2560 KB |
Output is correct |
81 |
Correct |
56 ms |
3796 KB |
Output is correct |
82 |
Correct |
85 ms |
5636 KB |
Output is correct |
83 |
Correct |
18 ms |
2644 KB |
Output is correct |
84 |
Correct |
83 ms |
5644 KB |
Output is correct |