#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
int n, k;
set<int> g[N];
set<pair<int, int>> st;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 0; i < n; i ++){
int x;
cin >> x;
for (int j = 0; j < x; j ++){
int v;
cin >> v;
g[i].insert(v);
}
st.insert({x, i});
}
int ans = 1;
while (!st.empty()){
auto p = *st.begin();
st.erase(st.begin());
int v = p.second;
vector<int> possible;
for (int u : g[v])
possible.push_back(u);
int sz = possible.size();
for (int mask = 1; mask < (1 << sz); mask ++){
vector<int> appeared;
bool good = 1;
for (int i = 0; i < sz; i ++){
if ((1 << i) & mask == 0) continue;
bool all = 1;
for (int x : appeared)
if (g[possible[i]].find(x) == g[possible[i]].end())
all = 0;
if (!all){
good = 0;
break;
}
appeared.push_back(possible[i]);
}
if (good)
ans = max(ans, (int)appeared.size() + 1);
}
for (int u : possible){
st.erase({g[u].size(), u});
g[u].erase(v);
st.insert({g[u].size(), u});
}
}
cout << ans << endl;
}
Compilation message
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:45:37: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
45 | if ((1 << i) & mask == 0) continue;
| ~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
4 ms |
3416 KB |
Output is correct |
4 |
Correct |
4 ms |
3420 KB |
Output is correct |
5 |
Correct |
4 ms |
3420 KB |
Output is correct |
6 |
Correct |
5 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
4 ms |
3416 KB |
Output is correct |
4 |
Correct |
4 ms |
3420 KB |
Output is correct |
5 |
Correct |
4 ms |
3420 KB |
Output is correct |
6 |
Correct |
5 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
4 ms |
3420 KB |
Output is correct |
12 |
Correct |
4 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
4 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
4 ms |
3420 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
3420 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
3 ms |
3164 KB |
Output is correct |
21 |
Correct |
3 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
5 ms |
3420 KB |
Output is correct |
24 |
Correct |
1 ms |
2904 KB |
Output is correct |
25 |
Correct |
5 ms |
3420 KB |
Output is correct |
26 |
Correct |
5 ms |
3420 KB |
Output is correct |
27 |
Correct |
4 ms |
3420 KB |
Output is correct |
28 |
Correct |
5 ms |
3420 KB |
Output is correct |
29 |
Correct |
4 ms |
3420 KB |
Output is correct |
30 |
Correct |
5 ms |
3420 KB |
Output is correct |
31 |
Correct |
6 ms |
3416 KB |
Output is correct |
32 |
Correct |
5 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3420 KB |
Output is correct |
34 |
Correct |
5 ms |
3420 KB |
Output is correct |
35 |
Correct |
3 ms |
3160 KB |
Output is correct |
36 |
Correct |
4 ms |
3236 KB |
Output is correct |
37 |
Correct |
3 ms |
3160 KB |
Output is correct |
38 |
Correct |
2 ms |
3104 KB |
Output is correct |
39 |
Correct |
2 ms |
3084 KB |
Output is correct |
40 |
Correct |
8 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2980 KB |
Output is correct |
42 |
Correct |
8 ms |
4184 KB |
Output is correct |
43 |
Correct |
8 ms |
3932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2988 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2808 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
322 ms |
26448 KB |
Output is correct |
12 |
Correct |
1 ms |
2648 KB |
Output is correct |
13 |
Correct |
315 ms |
26264 KB |
Output is correct |
14 |
Correct |
1 ms |
2648 KB |
Output is correct |
15 |
Correct |
313 ms |
26268 KB |
Output is correct |
16 |
Correct |
292 ms |
26264 KB |
Output is correct |
17 |
Correct |
349 ms |
26268 KB |
Output is correct |
18 |
Correct |
273 ms |
26192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
4 ms |
3416 KB |
Output is correct |
4 |
Correct |
4 ms |
3420 KB |
Output is correct |
5 |
Correct |
4 ms |
3420 KB |
Output is correct |
6 |
Correct |
5 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
4 ms |
3420 KB |
Output is correct |
12 |
Correct |
4 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
4 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
4 ms |
3420 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
3420 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
3 ms |
3164 KB |
Output is correct |
21 |
Correct |
3 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
5 ms |
3420 KB |
Output is correct |
24 |
Correct |
1 ms |
2904 KB |
Output is correct |
25 |
Correct |
5 ms |
3420 KB |
Output is correct |
26 |
Correct |
5 ms |
3420 KB |
Output is correct |
27 |
Correct |
4 ms |
3420 KB |
Output is correct |
28 |
Correct |
5 ms |
3420 KB |
Output is correct |
29 |
Correct |
4 ms |
3420 KB |
Output is correct |
30 |
Correct |
5 ms |
3420 KB |
Output is correct |
31 |
Correct |
6 ms |
3416 KB |
Output is correct |
32 |
Correct |
5 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3420 KB |
Output is correct |
34 |
Correct |
5 ms |
3420 KB |
Output is correct |
35 |
Correct |
3 ms |
3160 KB |
Output is correct |
36 |
Correct |
4 ms |
3236 KB |
Output is correct |
37 |
Correct |
3 ms |
3160 KB |
Output is correct |
38 |
Correct |
2 ms |
3104 KB |
Output is correct |
39 |
Correct |
2 ms |
3084 KB |
Output is correct |
40 |
Correct |
8 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2980 KB |
Output is correct |
42 |
Correct |
8 ms |
4184 KB |
Output is correct |
43 |
Correct |
8 ms |
3932 KB |
Output is correct |
44 |
Correct |
66 ms |
4696 KB |
Output is correct |
45 |
Correct |
1 ms |
2652 KB |
Output is correct |
46 |
Correct |
8 ms |
3848 KB |
Output is correct |
47 |
Correct |
16 ms |
4880 KB |
Output is correct |
48 |
Correct |
8 ms |
3928 KB |
Output is correct |
49 |
Correct |
18 ms |
4956 KB |
Output is correct |
50 |
Correct |
18 ms |
4956 KB |
Output is correct |
51 |
Correct |
77 ms |
7164 KB |
Output is correct |
52 |
Correct |
4 ms |
3332 KB |
Output is correct |
53 |
Correct |
91 ms |
7520 KB |
Output is correct |
54 |
Correct |
112 ms |
7676 KB |
Output is correct |
55 |
Correct |
4 ms |
3576 KB |
Output is correct |
56 |
Correct |
4 ms |
3420 KB |
Output is correct |
57 |
Correct |
2 ms |
2904 KB |
Output is correct |
58 |
Correct |
90 ms |
7672 KB |
Output is correct |
59 |
Correct |
8 ms |
3932 KB |
Output is correct |
60 |
Correct |
4 ms |
3420 KB |
Output is correct |
61 |
Correct |
8 ms |
3928 KB |
Output is correct |
62 |
Correct |
11 ms |
4188 KB |
Output is correct |
63 |
Correct |
65 ms |
4956 KB |
Output is correct |
64 |
Correct |
36 ms |
4700 KB |
Output is correct |
65 |
Correct |
9 ms |
3932 KB |
Output is correct |
66 |
Correct |
9 ms |
3932 KB |
Output is correct |
67 |
Correct |
34 ms |
5468 KB |
Output is correct |
68 |
Correct |
35 ms |
4840 KB |
Output is correct |
69 |
Correct |
7 ms |
3932 KB |
Output is correct |
70 |
Correct |
18 ms |
4904 KB |
Output is correct |
71 |
Correct |
41 ms |
5492 KB |
Output is correct |
72 |
Correct |
27 ms |
5212 KB |
Output is correct |
73 |
Correct |
5 ms |
3416 KB |
Output is correct |
74 |
Correct |
16 ms |
4696 KB |
Output is correct |
75 |
Correct |
26 ms |
5212 KB |
Output is correct |
76 |
Correct |
11 ms |
4224 KB |
Output is correct |
77 |
Correct |
31 ms |
5976 KB |
Output is correct |
78 |
Correct |
4 ms |
3420 KB |
Output is correct |
79 |
Correct |
22 ms |
4372 KB |
Output is correct |
80 |
Correct |
10 ms |
4440 KB |
Output is correct |
81 |
Correct |
31 ms |
5976 KB |
Output is correct |
82 |
Correct |
2 ms |
2908 KB |
Output is correct |
83 |
Correct |
15 ms |
4412 KB |
Output is correct |
84 |
Correct |
19 ms |
5368 KB |
Output is correct |
85 |
Correct |
2 ms |
2908 KB |
Output is correct |
86 |
Incorrect |
20 ms |
5208 KB |
Output isn't correct |
87 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
4 ms |
3416 KB |
Output is correct |
4 |
Correct |
4 ms |
3420 KB |
Output is correct |
5 |
Correct |
4 ms |
3420 KB |
Output is correct |
6 |
Correct |
5 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
4 ms |
3420 KB |
Output is correct |
12 |
Correct |
4 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
4 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
4 ms |
3420 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
3420 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
3 ms |
3164 KB |
Output is correct |
21 |
Correct |
3 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
5 ms |
3420 KB |
Output is correct |
24 |
Correct |
1 ms |
2904 KB |
Output is correct |
25 |
Correct |
5 ms |
3420 KB |
Output is correct |
26 |
Correct |
5 ms |
3420 KB |
Output is correct |
27 |
Correct |
4 ms |
3420 KB |
Output is correct |
28 |
Correct |
5 ms |
3420 KB |
Output is correct |
29 |
Correct |
4 ms |
3420 KB |
Output is correct |
30 |
Correct |
5 ms |
3420 KB |
Output is correct |
31 |
Correct |
6 ms |
3416 KB |
Output is correct |
32 |
Correct |
5 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3420 KB |
Output is correct |
34 |
Correct |
5 ms |
3420 KB |
Output is correct |
35 |
Correct |
3 ms |
3160 KB |
Output is correct |
36 |
Correct |
4 ms |
3236 KB |
Output is correct |
37 |
Correct |
3 ms |
3160 KB |
Output is correct |
38 |
Correct |
2 ms |
3104 KB |
Output is correct |
39 |
Correct |
2 ms |
3084 KB |
Output is correct |
40 |
Correct |
8 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2980 KB |
Output is correct |
42 |
Correct |
8 ms |
4184 KB |
Output is correct |
43 |
Correct |
8 ms |
3932 KB |
Output is correct |
44 |
Correct |
1 ms |
2648 KB |
Output is correct |
45 |
Correct |
185 ms |
19188 KB |
Output is correct |
46 |
Correct |
60 ms |
12120 KB |
Output is correct |
47 |
Correct |
173 ms |
19028 KB |
Output is correct |
48 |
Correct |
186 ms |
19044 KB |
Output is correct |
49 |
Correct |
45 ms |
9816 KB |
Output is correct |
50 |
Correct |
153 ms |
23892 KB |
Output is correct |
51 |
Correct |
161 ms |
19036 KB |
Output is correct |
52 |
Correct |
40 ms |
9676 KB |
Output is correct |
53 |
Correct |
50 ms |
9812 KB |
Output is correct |
54 |
Correct |
10 ms |
4952 KB |
Output is correct |
55 |
Correct |
177 ms |
23916 KB |
Output is correct |
56 |
Correct |
23 ms |
7260 KB |
Output is correct |
57 |
Correct |
41 ms |
9820 KB |
Output is correct |
58 |
Correct |
54 ms |
12124 KB |
Output is correct |
59 |
Correct |
32 ms |
7608 KB |
Output is correct |
60 |
Correct |
23 ms |
7256 KB |
Output is correct |
61 |
Correct |
58 ms |
12116 KB |
Output is correct |
62 |
Correct |
39 ms |
9816 KB |
Output is correct |
63 |
Correct |
95 ms |
13136 KB |
Output is correct |
64 |
Correct |
23 ms |
7260 KB |
Output is correct |
65 |
Correct |
121 ms |
15712 KB |
Output is correct |
66 |
Correct |
39 ms |
9820 KB |
Output is correct |
67 |
Correct |
89 ms |
13148 KB |
Output is correct |
68 |
Correct |
122 ms |
14928 KB |
Output is correct |
69 |
Correct |
139 ms |
15628 KB |
Output is correct |
70 |
Correct |
39 ms |
9820 KB |
Output is correct |
71 |
Correct |
158 ms |
15136 KB |
Output is correct |
72 |
Correct |
94 ms |
12956 KB |
Output is correct |
73 |
Correct |
136 ms |
16956 KB |
Output is correct |
74 |
Correct |
37 ms |
9816 KB |
Output is correct |
75 |
Correct |
44 ms |
8540 KB |
Output is correct |
76 |
Correct |
74 ms |
12952 KB |
Output is correct |
77 |
Correct |
124 ms |
16976 KB |
Output is correct |
78 |
Correct |
53 ms |
9996 KB |
Output is correct |
79 |
Correct |
49 ms |
8524 KB |
Output is correct |
80 |
Correct |
19 ms |
5468 KB |
Output is correct |
81 |
Correct |
55 ms |
9996 KB |
Output is correct |
82 |
Correct |
91 ms |
14524 KB |
Output is correct |
83 |
Correct |
18 ms |
5468 KB |
Output is correct |
84 |
Incorrect |
88 ms |
14396 KB |
Output isn't correct |
85 |
Halted |
0 ms |
0 KB |
- |