#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 50000;
int n, k;
int deg[N];
vector<int> g[N];
bitset<N> yes[N];
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int> > > pq;
for(int i = 0;i < n; i++){
int sz; cin >> sz;
deg[i] = sz;
pq.push({deg[i], i});
yes[i][i] = 1;
for(int j = 0;j < sz; j++){
int x; cin >> x;
yes[i][x] = 1;
g[i].push_back(x);
}
}
int ans = 1;
vector<int> used(n, 0);
while(true){
while(!pq.empty() && (used[pq.top().ss] || pq.top().ff != deg[pq.top().ss])) pq.pop();
if(pq.empty()) break;
int v = pq.top().ss;
pq.pop();
used[v] = 1;
vector<int> vert = {v};
for(int to : g[v]){
if(used[to]) continue;
deg[to]--;
pq.push({deg[to], to});
vert.push_back(to);
}
for(int mask = 1; mask < (1<<vert.size()); mask++){
int ok = 1, cnt = 0;
for(int i = 0;i < vert.size() && ok; i++){
if(!(mask & (1<<i))) continue;
cnt++;
for(int j = 0;j < vert.size(); j++){
if(mask & (1<<j)){
if(yes[vert[i]][vert[j]] == 0){
ok = 0;
break;
}
}
}
}
if(ok){
if(cnt > k) assert(false);
ans = max(ans, cnt);
}
}
}
cout << ans;
return 0;
}
Compilation message
politicaldevelopment.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main(){
| ^~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0;i < vert.size() && ok; i++){
| ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int j = 0;j < vert.size(); j++){
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
32652 KB |
Output is correct |
4 |
Correct |
6 ms |
32604 KB |
Output is correct |
5 |
Correct |
6 ms |
32604 KB |
Output is correct |
6 |
Correct |
6 ms |
32604 KB |
Output is correct |
7 |
Correct |
6 ms |
32604 KB |
Output is correct |
8 |
Correct |
4 ms |
32604 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
32652 KB |
Output is correct |
4 |
Correct |
6 ms |
32604 KB |
Output is correct |
5 |
Correct |
6 ms |
32604 KB |
Output is correct |
6 |
Correct |
6 ms |
32604 KB |
Output is correct |
7 |
Correct |
6 ms |
32604 KB |
Output is correct |
8 |
Correct |
4 ms |
32604 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32604 KB |
Output is correct |
11 |
Correct |
6 ms |
32600 KB |
Output is correct |
12 |
Correct |
6 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
6 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
32604 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
32652 KB |
Output is correct |
19 |
Correct |
4 ms |
32604 KB |
Output is correct |
20 |
Correct |
6 ms |
32604 KB |
Output is correct |
21 |
Correct |
5 ms |
32604 KB |
Output is correct |
22 |
Correct |
4 ms |
32604 KB |
Output is correct |
23 |
Correct |
7 ms |
32604 KB |
Output is correct |
24 |
Correct |
4 ms |
32604 KB |
Output is correct |
25 |
Correct |
7 ms |
32604 KB |
Output is correct |
26 |
Correct |
7 ms |
32604 KB |
Output is correct |
27 |
Correct |
7 ms |
32600 KB |
Output is correct |
28 |
Correct |
7 ms |
32604 KB |
Output is correct |
29 |
Correct |
6 ms |
32604 KB |
Output is correct |
30 |
Correct |
7 ms |
32604 KB |
Output is correct |
31 |
Correct |
7 ms |
32808 KB |
Output is correct |
32 |
Correct |
7 ms |
32604 KB |
Output is correct |
33 |
Correct |
7 ms |
32660 KB |
Output is correct |
34 |
Correct |
7 ms |
32604 KB |
Output is correct |
35 |
Correct |
4 ms |
18268 KB |
Output is correct |
36 |
Correct |
4 ms |
18268 KB |
Output is correct |
37 |
Correct |
4 ms |
18268 KB |
Output is correct |
38 |
Correct |
2 ms |
9820 KB |
Output is correct |
39 |
Correct |
3 ms |
9820 KB |
Output is correct |
40 |
Correct |
11 ms |
33016 KB |
Output is correct |
41 |
Correct |
2 ms |
9820 KB |
Output is correct |
42 |
Correct |
9 ms |
32792 KB |
Output is correct |
43 |
Correct |
8 ms |
32860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
32604 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1628 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1672 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
238 ms |
313924 KB |
Output is correct |
12 |
Correct |
1 ms |
1624 KB |
Output is correct |
13 |
Correct |
235 ms |
313796 KB |
Output is correct |
14 |
Correct |
1 ms |
1628 KB |
Output is correct |
15 |
Correct |
239 ms |
313916 KB |
Output is correct |
16 |
Correct |
238 ms |
313876 KB |
Output is correct |
17 |
Correct |
233 ms |
313804 KB |
Output is correct |
18 |
Correct |
238 ms |
314048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
32652 KB |
Output is correct |
4 |
Correct |
6 ms |
32604 KB |
Output is correct |
5 |
Correct |
6 ms |
32604 KB |
Output is correct |
6 |
Correct |
6 ms |
32604 KB |
Output is correct |
7 |
Correct |
6 ms |
32604 KB |
Output is correct |
8 |
Correct |
4 ms |
32604 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32604 KB |
Output is correct |
11 |
Correct |
6 ms |
32600 KB |
Output is correct |
12 |
Correct |
6 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
6 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
32604 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
32652 KB |
Output is correct |
19 |
Correct |
4 ms |
32604 KB |
Output is correct |
20 |
Correct |
6 ms |
32604 KB |
Output is correct |
21 |
Correct |
5 ms |
32604 KB |
Output is correct |
22 |
Correct |
4 ms |
32604 KB |
Output is correct |
23 |
Correct |
7 ms |
32604 KB |
Output is correct |
24 |
Correct |
4 ms |
32604 KB |
Output is correct |
25 |
Correct |
7 ms |
32604 KB |
Output is correct |
26 |
Correct |
7 ms |
32604 KB |
Output is correct |
27 |
Correct |
7 ms |
32600 KB |
Output is correct |
28 |
Correct |
7 ms |
32604 KB |
Output is correct |
29 |
Correct |
6 ms |
32604 KB |
Output is correct |
30 |
Correct |
7 ms |
32604 KB |
Output is correct |
31 |
Correct |
7 ms |
32808 KB |
Output is correct |
32 |
Correct |
7 ms |
32604 KB |
Output is correct |
33 |
Correct |
7 ms |
32660 KB |
Output is correct |
34 |
Correct |
7 ms |
32604 KB |
Output is correct |
35 |
Correct |
4 ms |
18268 KB |
Output is correct |
36 |
Correct |
4 ms |
18268 KB |
Output is correct |
37 |
Correct |
4 ms |
18268 KB |
Output is correct |
38 |
Correct |
2 ms |
9820 KB |
Output is correct |
39 |
Correct |
3 ms |
9820 KB |
Output is correct |
40 |
Correct |
11 ms |
33016 KB |
Output is correct |
41 |
Correct |
2 ms |
9820 KB |
Output is correct |
42 |
Correct |
9 ms |
32792 KB |
Output is correct |
43 |
Correct |
8 ms |
32860 KB |
Output is correct |
44 |
Correct |
88 ms |
32856 KB |
Output is correct |
45 |
Correct |
1 ms |
1624 KB |
Output is correct |
46 |
Correct |
9 ms |
32892 KB |
Output is correct |
47 |
Correct |
13 ms |
33116 KB |
Output is correct |
48 |
Correct |
9 ms |
32860 KB |
Output is correct |
49 |
Correct |
14 ms |
33116 KB |
Output is correct |
50 |
Correct |
14 ms |
33040 KB |
Output is correct |
51 |
Correct |
59 ms |
33604 KB |
Output is correct |
52 |
Correct |
6 ms |
32600 KB |
Output is correct |
53 |
Correct |
103 ms |
33648 KB |
Output is correct |
54 |
Correct |
113 ms |
33656 KB |
Output is correct |
55 |
Correct |
7 ms |
32600 KB |
Output is correct |
56 |
Correct |
6 ms |
32604 KB |
Output is correct |
57 |
Correct |
5 ms |
32604 KB |
Output is correct |
58 |
Correct |
111 ms |
33860 KB |
Output is correct |
59 |
Correct |
10 ms |
32604 KB |
Output is correct |
60 |
Correct |
7 ms |
32604 KB |
Output is correct |
61 |
Correct |
9 ms |
32604 KB |
Output is correct |
62 |
Correct |
9 ms |
32556 KB |
Output is correct |
63 |
Correct |
88 ms |
32860 KB |
Output is correct |
64 |
Correct |
37 ms |
32860 KB |
Output is correct |
65 |
Correct |
8 ms |
32856 KB |
Output is correct |
66 |
Correct |
9 ms |
32604 KB |
Output is correct |
67 |
Correct |
38 ms |
33088 KB |
Output is correct |
68 |
Correct |
34 ms |
32860 KB |
Output is correct |
69 |
Correct |
8 ms |
32856 KB |
Output is correct |
70 |
Correct |
13 ms |
32860 KB |
Output is correct |
71 |
Correct |
37 ms |
33116 KB |
Output is correct |
72 |
Correct |
23 ms |
33116 KB |
Output is correct |
73 |
Correct |
6 ms |
32600 KB |
Output is correct |
74 |
Correct |
14 ms |
33044 KB |
Output is correct |
75 |
Correct |
23 ms |
33116 KB |
Output is correct |
76 |
Correct |
10 ms |
32860 KB |
Output is correct |
77 |
Correct |
28 ms |
33232 KB |
Output is correct |
78 |
Correct |
7 ms |
32604 KB |
Output is correct |
79 |
Correct |
15 ms |
18516 KB |
Output is correct |
80 |
Correct |
10 ms |
32876 KB |
Output is correct |
81 |
Correct |
30 ms |
33228 KB |
Output is correct |
82 |
Correct |
2 ms |
10076 KB |
Output is correct |
83 |
Correct |
15 ms |
18520 KB |
Output is correct |
84 |
Correct |
18 ms |
33240 KB |
Output is correct |
85 |
Correct |
2 ms |
9820 KB |
Output is correct |
86 |
Correct |
18 ms |
33292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
32652 KB |
Output is correct |
4 |
Correct |
6 ms |
32604 KB |
Output is correct |
5 |
Correct |
6 ms |
32604 KB |
Output is correct |
6 |
Correct |
6 ms |
32604 KB |
Output is correct |
7 |
Correct |
6 ms |
32604 KB |
Output is correct |
8 |
Correct |
4 ms |
32604 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32604 KB |
Output is correct |
11 |
Correct |
6 ms |
32600 KB |
Output is correct |
12 |
Correct |
6 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
6 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
32604 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
32652 KB |
Output is correct |
19 |
Correct |
4 ms |
32604 KB |
Output is correct |
20 |
Correct |
6 ms |
32604 KB |
Output is correct |
21 |
Correct |
5 ms |
32604 KB |
Output is correct |
22 |
Correct |
4 ms |
32604 KB |
Output is correct |
23 |
Correct |
7 ms |
32604 KB |
Output is correct |
24 |
Correct |
4 ms |
32604 KB |
Output is correct |
25 |
Correct |
7 ms |
32604 KB |
Output is correct |
26 |
Correct |
7 ms |
32604 KB |
Output is correct |
27 |
Correct |
7 ms |
32600 KB |
Output is correct |
28 |
Correct |
7 ms |
32604 KB |
Output is correct |
29 |
Correct |
6 ms |
32604 KB |
Output is correct |
30 |
Correct |
7 ms |
32604 KB |
Output is correct |
31 |
Correct |
7 ms |
32808 KB |
Output is correct |
32 |
Correct |
7 ms |
32604 KB |
Output is correct |
33 |
Correct |
7 ms |
32660 KB |
Output is correct |
34 |
Correct |
7 ms |
32604 KB |
Output is correct |
35 |
Correct |
4 ms |
18268 KB |
Output is correct |
36 |
Correct |
4 ms |
18268 KB |
Output is correct |
37 |
Correct |
4 ms |
18268 KB |
Output is correct |
38 |
Correct |
2 ms |
9820 KB |
Output is correct |
39 |
Correct |
3 ms |
9820 KB |
Output is correct |
40 |
Correct |
11 ms |
33016 KB |
Output is correct |
41 |
Correct |
2 ms |
9820 KB |
Output is correct |
42 |
Correct |
9 ms |
32792 KB |
Output is correct |
43 |
Correct |
8 ms |
32860 KB |
Output is correct |
44 |
Correct |
1 ms |
1628 KB |
Output is correct |
45 |
Correct |
126 ms |
312260 KB |
Output is correct |
46 |
Correct |
75 ms |
310216 KB |
Output is correct |
47 |
Correct |
137 ms |
312328 KB |
Output is correct |
48 |
Correct |
125 ms |
312384 KB |
Output is correct |
49 |
Correct |
57 ms |
310096 KB |
Output is correct |
50 |
Correct |
121 ms |
312512 KB |
Output is correct |
51 |
Correct |
152 ms |
312696 KB |
Output is correct |
52 |
Correct |
58 ms |
310216 KB |
Output is correct |
53 |
Correct |
55 ms |
309964 KB |
Output is correct |
54 |
Correct |
36 ms |
308184 KB |
Output is correct |
55 |
Correct |
125 ms |
312432 KB |
Output is correct |
56 |
Correct |
50 ms |
309968 KB |
Output is correct |
57 |
Correct |
59 ms |
309964 KB |
Output is correct |
58 |
Correct |
74 ms |
309964 KB |
Output is correct |
59 |
Correct |
51 ms |
309964 KB |
Output is correct |
60 |
Correct |
50 ms |
309960 KB |
Output is correct |
61 |
Correct |
73 ms |
309956 KB |
Output is correct |
62 |
Correct |
61 ms |
309844 KB |
Output is correct |
63 |
Correct |
87 ms |
310728 KB |
Output is correct |
64 |
Correct |
50 ms |
309960 KB |
Output is correct |
65 |
Correct |
106 ms |
310908 KB |
Output is correct |
66 |
Correct |
63 ms |
309972 KB |
Output is correct |
67 |
Correct |
88 ms |
310732 KB |
Output is correct |
68 |
Correct |
101 ms |
310988 KB |
Output is correct |
69 |
Correct |
104 ms |
310860 KB |
Output is correct |
70 |
Correct |
64 ms |
309884 KB |
Output is correct |
71 |
Correct |
105 ms |
310988 KB |
Output is correct |
72 |
Correct |
80 ms |
310728 KB |
Output is correct |
73 |
Correct |
114 ms |
311144 KB |
Output is correct |
74 |
Correct |
63 ms |
309964 KB |
Output is correct |
75 |
Correct |
46 ms |
157132 KB |
Output is correct |
76 |
Correct |
81 ms |
310704 KB |
Output is correct |
77 |
Correct |
119 ms |
311048 KB |
Output is correct |
78 |
Correct |
57 ms |
157248 KB |
Output is correct |
79 |
Correct |
46 ms |
157132 KB |
Output is correct |
80 |
Correct |
20 ms |
80476 KB |
Output is correct |
81 |
Correct |
56 ms |
157392 KB |
Output is correct |
82 |
Correct |
95 ms |
310476 KB |
Output is correct |
83 |
Correct |
20 ms |
80484 KB |
Output is correct |
84 |
Correct |
91 ms |
310468 KB |
Output is correct |