#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';
}
Compilation message
politicaldevelopment.cpp: In function 'bool ok(int)':
politicaldevelopment.cpp:11:23: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
11 | if((mask>>i)&1==0) continue;
| ~^~~
politicaldevelopment.cpp:13:27: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
13 | if((mask>>j)&1==0) continue;
| ~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1860 KB |
Output is correct |
5 |
Correct |
4 ms |
1876 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
4 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 |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1860 KB |
Output is correct |
5 |
Correct |
4 ms |
1876 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
4 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 |
1876 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 |
5 ms |
1916 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
6 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1748 KB |
Output is correct |
20 |
Correct |
4 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 |
6 ms |
1876 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
5 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1876 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
5 ms |
1876 KB |
Output is correct |
29 |
Correct |
4 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1876 KB |
Output is correct |
32 |
Correct |
8 ms |
1944 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1876 KB |
Output is correct |
35 |
Correct |
3 ms |
1716 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 |
7 ms |
1876 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
8 ms |
1952 KB |
Output is correct |
43 |
Correct |
8 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
2 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 |
277 ms |
7980 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
279 ms |
7916 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
289 ms |
8096 KB |
Output is correct |
16 |
Correct |
294 ms |
8008 KB |
Output is correct |
17 |
Correct |
311 ms |
8056 KB |
Output is correct |
18 |
Correct |
277 ms |
8052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1860 KB |
Output is correct |
5 |
Correct |
4 ms |
1876 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
4 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 |
1876 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 |
5 ms |
1916 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
6 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1748 KB |
Output is correct |
20 |
Correct |
4 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 |
6 ms |
1876 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
5 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1876 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
5 ms |
1876 KB |
Output is correct |
29 |
Correct |
4 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1876 KB |
Output is correct |
32 |
Correct |
8 ms |
1944 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1876 KB |
Output is correct |
35 |
Correct |
3 ms |
1716 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 |
7 ms |
1876 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
8 ms |
1952 KB |
Output is correct |
43 |
Correct |
8 ms |
1876 KB |
Output is correct |
44 |
Correct |
9 ms |
1876 KB |
Output is correct |
45 |
Correct |
2 ms |
1484 KB |
Output is correct |
46 |
Correct |
9 ms |
1956 KB |
Output is correct |
47 |
Correct |
19 ms |
2004 KB |
Output is correct |
48 |
Correct |
10 ms |
1876 KB |
Output is correct |
49 |
Correct |
17 ms |
2004 KB |
Output is correct |
50 |
Correct |
16 ms |
2004 KB |
Output is correct |
51 |
Correct |
89 ms |
2280 KB |
Output is correct |
52 |
Correct |
3 ms |
1876 KB |
Output is correct |
53 |
Correct |
246 ms |
2352 KB |
Output is correct |
54 |
Correct |
162 ms |
2320 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 |
231 ms |
2344 KB |
Output is correct |
59 |
Correct |
6 ms |
1876 KB |
Output is correct |
60 |
Correct |
5 ms |
1948 KB |
Output is correct |
61 |
Correct |
6 ms |
1876 KB |
Output is correct |
62 |
Correct |
6 ms |
1900 KB |
Output is correct |
63 |
Correct |
10 ms |
1932 KB |
Output is correct |
64 |
Correct |
9 ms |
1876 KB |
Output is correct |
65 |
Correct |
7 ms |
1944 KB |
Output is correct |
66 |
Correct |
7 ms |
1836 KB |
Output is correct |
67 |
Correct |
23 ms |
2108 KB |
Output is correct |
68 |
Correct |
8 ms |
1992 KB |
Output is correct |
69 |
Correct |
7 ms |
1876 KB |
Output is correct |
70 |
Correct |
12 ms |
1940 KB |
Output is correct |
71 |
Correct |
20 ms |
2104 KB |
Output is correct |
72 |
Correct |
19 ms |
2088 KB |
Output is correct |
73 |
Correct |
4 ms |
1876 KB |
Output is correct |
74 |
Correct |
13 ms |
2004 KB |
Output is correct |
75 |
Correct |
21 ms |
2004 KB |
Output is correct |
76 |
Correct |
10 ms |
1876 KB |
Output is correct |
77 |
Correct |
38 ms |
2148 KB |
Output is correct |
78 |
Correct |
5 ms |
1876 KB |
Output is correct |
79 |
Correct |
19 ms |
1748 KB |
Output is correct |
80 |
Correct |
12 ms |
1940 KB |
Output is correct |
81 |
Correct |
41 ms |
2132 KB |
Output is correct |
82 |
Correct |
3 ms |
1492 KB |
Output is correct |
83 |
Correct |
20 ms |
1748 KB |
Output is correct |
84 |
Correct |
24 ms |
2252 KB |
Output is correct |
85 |
Correct |
3 ms |
1624 KB |
Output is correct |
86 |
Incorrect |
23 ms |
2160 KB |
Output isn't correct |
87 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
5 ms |
1876 KB |
Output is correct |
4 |
Correct |
4 ms |
1860 KB |
Output is correct |
5 |
Correct |
4 ms |
1876 KB |
Output is correct |
6 |
Correct |
5 ms |
1876 KB |
Output is correct |
7 |
Correct |
4 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 |
1876 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 |
5 ms |
1916 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
6 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1748 KB |
Output is correct |
20 |
Correct |
4 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 |
6 ms |
1876 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
5 ms |
1876 KB |
Output is correct |
26 |
Correct |
6 ms |
1876 KB |
Output is correct |
27 |
Correct |
6 ms |
1876 KB |
Output is correct |
28 |
Correct |
5 ms |
1876 KB |
Output is correct |
29 |
Correct |
4 ms |
1876 KB |
Output is correct |
30 |
Correct |
5 ms |
1876 KB |
Output is correct |
31 |
Correct |
6 ms |
1876 KB |
Output is correct |
32 |
Correct |
8 ms |
1944 KB |
Output is correct |
33 |
Correct |
6 ms |
1876 KB |
Output is correct |
34 |
Correct |
6 ms |
1876 KB |
Output is correct |
35 |
Correct |
3 ms |
1716 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 |
7 ms |
1876 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
8 ms |
1952 KB |
Output is correct |
43 |
Correct |
8 ms |
1876 KB |
Output is correct |
44 |
Correct |
1 ms |
1492 KB |
Output is correct |
45 |
Correct |
161 ms |
6316 KB |
Output is correct |
46 |
Correct |
68 ms |
5740 KB |
Output is correct |
47 |
Correct |
155 ms |
6436 KB |
Output is correct |
48 |
Correct |
158 ms |
6396 KB |
Output is correct |
49 |
Correct |
40 ms |
5792 KB |
Output is correct |
50 |
Correct |
186 ms |
6472 KB |
Output is correct |
51 |
Correct |
160 ms |
6432 KB |
Output is correct |
52 |
Correct |
39 ms |
5816 KB |
Output is correct |
53 |
Correct |
38 ms |
5844 KB |
Output is correct |
54 |
Correct |
14 ms |
4072 KB |
Output is correct |
55 |
Correct |
202 ms |
6656 KB |
Output is correct |
56 |
Correct |
27 ms |
5596 KB |
Output is correct |
57 |
Correct |
38 ms |
5768 KB |
Output is correct |
58 |
Correct |
49 ms |
5640 KB |
Output is correct |
59 |
Correct |
36 ms |
5624 KB |
Output is correct |
60 |
Correct |
31 ms |
5640 KB |
Output is correct |
61 |
Correct |
50 ms |
5612 KB |
Output is correct |
62 |
Correct |
47 ms |
5636 KB |
Output is correct |
63 |
Correct |
83 ms |
5840 KB |
Output is correct |
64 |
Correct |
28 ms |
5604 KB |
Output is correct |
65 |
Correct |
100 ms |
6072 KB |
Output is correct |
66 |
Correct |
41 ms |
5588 KB |
Output is correct |
67 |
Correct |
86 ms |
5848 KB |
Output is correct |
68 |
Correct |
96 ms |
6000 KB |
Output is correct |
69 |
Correct |
103 ms |
6072 KB |
Output is correct |
70 |
Correct |
47 ms |
5752 KB |
Output is correct |
71 |
Correct |
106 ms |
5980 KB |
Output is correct |
72 |
Correct |
65 ms |
5764 KB |
Output is correct |
73 |
Correct |
160 ms |
6092 KB |
Output is correct |
74 |
Correct |
42 ms |
5636 KB |
Output is correct |
75 |
Correct |
45 ms |
3668 KB |
Output is correct |
76 |
Correct |
70 ms |
5884 KB |
Output is correct |
77 |
Correct |
127 ms |
6092 KB |
Output is correct |
78 |
Correct |
64 ms |
3924 KB |
Output is correct |
79 |
Correct |
56 ms |
3668 KB |
Output is correct |
80 |
Correct |
22 ms |
2648 KB |
Output is correct |
81 |
Correct |
59 ms |
3740 KB |
Output is correct |
82 |
Correct |
87 ms |
5640 KB |
Output is correct |
83 |
Correct |
28 ms |
2648 KB |
Output is correct |
84 |
Incorrect |
90 ms |
5640 KB |
Output isn't correct |
85 |
Halted |
0 ms |
0 KB |
- |