#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int N = 5e4, X = 5e5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k, c, ans;
vector<int> vt, adj[N];
bitset<N> bt[N], bt2[N], r, taken, toTake;
void clean(int x) {
for (int i = 0; i < n; i++) {
if (adj[i].size()+1 < x) r[i] = 1;
}
}
void dfs(int x) {
if (c++ > X) return;
int sz = taken.count();
if (sz > ans) {
ans = sz;
clean(sz+1);
}
shuffle(all(adj[x]), rng);
for (int& y : adj[x]) {
if (c++ > X) return;
if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
taken[y] = 1;
bitset<N> toTakePrev = toTake;
toTake &= bt2[y];
dfs(y);
toTake = toTakePrev;
taken[y] = 0;
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> k;
ans = 1;
vt.resize(n);
for (int i = 0; i < n; i++) {
vt[i] = i;
bt2[i][i] = toTake[i] = 1;
int x; cin >> x;
for (int j = 0; j < x; j++) {
int y; cin >> y;
bt[i][y] = 1;
if (bt[y][i]) {
bt2[i][y] = 1;
adj[i].push_back(y);
bt2[y][i] = 1;
adj[y].push_back(i);
}
}
}
for (int i = 0; i < n; i++) {
if (r[i]) continue;
c = 0;
taken.reset();
taken[i] = 1;
toTake = bt2[i];
dfs(i);
}
cout << ans << "\n";
}
Compilation message
politicaldevelopment.cpp: In function 'void clean(int)':
politicaldevelopment.cpp:18:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | if (adj[i].size()+1 < x) r[i] = 1;
| ~~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:34:54: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
34 | if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1724 KB |
Output is correct |
3 |
Correct |
31 ms |
43864 KB |
Output is correct |
4 |
Correct |
17 ms |
42844 KB |
Output is correct |
5 |
Correct |
18 ms |
42712 KB |
Output is correct |
6 |
Correct |
20 ms |
43096 KB |
Output is correct |
7 |
Correct |
19 ms |
43100 KB |
Output is correct |
8 |
Correct |
12 ms |
21596 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
7 ms |
21596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1724 KB |
Output is correct |
3 |
Correct |
31 ms |
43864 KB |
Output is correct |
4 |
Correct |
17 ms |
42844 KB |
Output is correct |
5 |
Correct |
18 ms |
42712 KB |
Output is correct |
6 |
Correct |
20 ms |
43096 KB |
Output is correct |
7 |
Correct |
19 ms |
43100 KB |
Output is correct |
8 |
Correct |
12 ms |
21596 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
7 ms |
21596 KB |
Output is correct |
11 |
Correct |
17 ms |
42844 KB |
Output is correct |
12 |
Correct |
16 ms |
42836 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
17 ms |
42748 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
20 ms |
42896 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
21 ms |
42972 KB |
Output is correct |
19 |
Correct |
12 ms |
21596 KB |
Output is correct |
20 |
Correct |
20 ms |
42844 KB |
Output is correct |
21 |
Correct |
16 ms |
42844 KB |
Output is correct |
22 |
Correct |
8 ms |
21596 KB |
Output is correct |
23 |
Correct |
30 ms |
44684 KB |
Output is correct |
24 |
Correct |
8 ms |
21596 KB |
Output is correct |
25 |
Correct |
34 ms |
44636 KB |
Output is correct |
26 |
Correct |
43 ms |
43608 KB |
Output is correct |
27 |
Correct |
40 ms |
44380 KB |
Output is correct |
28 |
Correct |
41 ms |
43608 KB |
Output is correct |
29 |
Correct |
42 ms |
44380 KB |
Output is correct |
30 |
Correct |
1145 ms |
44328 KB |
Output is correct |
31 |
Correct |
56 ms |
45136 KB |
Output is correct |
32 |
Correct |
1267 ms |
44376 KB |
Output is correct |
33 |
Correct |
56 ms |
44892 KB |
Output is correct |
34 |
Correct |
53 ms |
44892 KB |
Output is correct |
35 |
Correct |
27 ms |
22364 KB |
Output is correct |
36 |
Correct |
29 ms |
22364 KB |
Output is correct |
37 |
Correct |
26 ms |
22364 KB |
Output is correct |
38 |
Correct |
52 ms |
11612 KB |
Output is correct |
39 |
Correct |
51 ms |
11608 KB |
Output is correct |
40 |
Correct |
73 ms |
45400 KB |
Output is correct |
41 |
Correct |
53 ms |
11608 KB |
Output is correct |
42 |
Correct |
70 ms |
45400 KB |
Output is correct |
43 |
Correct |
74 ms |
45492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
21596 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 |
2 ms |
1628 KB |
Output is correct |
6 |
Correct |
2 ms |
1628 KB |
Output is correct |
7 |
Correct |
2 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
2 ms |
1628 KB |
Output is correct |
10 |
Correct |
2 ms |
1704 KB |
Output is correct |
11 |
Runtime error |
277 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1724 KB |
Output is correct |
3 |
Correct |
31 ms |
43864 KB |
Output is correct |
4 |
Correct |
17 ms |
42844 KB |
Output is correct |
5 |
Correct |
18 ms |
42712 KB |
Output is correct |
6 |
Correct |
20 ms |
43096 KB |
Output is correct |
7 |
Correct |
19 ms |
43100 KB |
Output is correct |
8 |
Correct |
12 ms |
21596 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
7 ms |
21596 KB |
Output is correct |
11 |
Correct |
17 ms |
42844 KB |
Output is correct |
12 |
Correct |
16 ms |
42836 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
17 ms |
42748 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
20 ms |
42896 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
21 ms |
42972 KB |
Output is correct |
19 |
Correct |
12 ms |
21596 KB |
Output is correct |
20 |
Correct |
20 ms |
42844 KB |
Output is correct |
21 |
Correct |
16 ms |
42844 KB |
Output is correct |
22 |
Correct |
8 ms |
21596 KB |
Output is correct |
23 |
Correct |
30 ms |
44684 KB |
Output is correct |
24 |
Correct |
8 ms |
21596 KB |
Output is correct |
25 |
Correct |
34 ms |
44636 KB |
Output is correct |
26 |
Correct |
43 ms |
43608 KB |
Output is correct |
27 |
Correct |
40 ms |
44380 KB |
Output is correct |
28 |
Correct |
41 ms |
43608 KB |
Output is correct |
29 |
Correct |
42 ms |
44380 KB |
Output is correct |
30 |
Correct |
1145 ms |
44328 KB |
Output is correct |
31 |
Correct |
56 ms |
45136 KB |
Output is correct |
32 |
Correct |
1267 ms |
44376 KB |
Output is correct |
33 |
Correct |
56 ms |
44892 KB |
Output is correct |
34 |
Correct |
53 ms |
44892 KB |
Output is correct |
35 |
Correct |
27 ms |
22364 KB |
Output is correct |
36 |
Correct |
29 ms |
22364 KB |
Output is correct |
37 |
Correct |
26 ms |
22364 KB |
Output is correct |
38 |
Correct |
52 ms |
11612 KB |
Output is correct |
39 |
Correct |
51 ms |
11608 KB |
Output is correct |
40 |
Correct |
73 ms |
45400 KB |
Output is correct |
41 |
Correct |
53 ms |
11608 KB |
Output is correct |
42 |
Correct |
70 ms |
45400 KB |
Output is correct |
43 |
Correct |
74 ms |
45492 KB |
Output is correct |
44 |
Correct |
23 ms |
46684 KB |
Output is correct |
45 |
Correct |
1 ms |
1624 KB |
Output is correct |
46 |
Correct |
61 ms |
45312 KB |
Output is correct |
47 |
Correct |
269 ms |
46672 KB |
Output is correct |
48 |
Correct |
78 ms |
45148 KB |
Output is correct |
49 |
Correct |
258 ms |
46584 KB |
Output is correct |
50 |
Correct |
303 ms |
46432 KB |
Output is correct |
51 |
Execution timed out |
3086 ms |
47444 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1724 KB |
Output is correct |
3 |
Correct |
31 ms |
43864 KB |
Output is correct |
4 |
Correct |
17 ms |
42844 KB |
Output is correct |
5 |
Correct |
18 ms |
42712 KB |
Output is correct |
6 |
Correct |
20 ms |
43096 KB |
Output is correct |
7 |
Correct |
19 ms |
43100 KB |
Output is correct |
8 |
Correct |
12 ms |
21596 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
7 ms |
21596 KB |
Output is correct |
11 |
Correct |
17 ms |
42844 KB |
Output is correct |
12 |
Correct |
16 ms |
42836 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
17 ms |
42748 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
20 ms |
42896 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
21 ms |
42972 KB |
Output is correct |
19 |
Correct |
12 ms |
21596 KB |
Output is correct |
20 |
Correct |
20 ms |
42844 KB |
Output is correct |
21 |
Correct |
16 ms |
42844 KB |
Output is correct |
22 |
Correct |
8 ms |
21596 KB |
Output is correct |
23 |
Correct |
30 ms |
44684 KB |
Output is correct |
24 |
Correct |
8 ms |
21596 KB |
Output is correct |
25 |
Correct |
34 ms |
44636 KB |
Output is correct |
26 |
Correct |
43 ms |
43608 KB |
Output is correct |
27 |
Correct |
40 ms |
44380 KB |
Output is correct |
28 |
Correct |
41 ms |
43608 KB |
Output is correct |
29 |
Correct |
42 ms |
44380 KB |
Output is correct |
30 |
Correct |
1145 ms |
44328 KB |
Output is correct |
31 |
Correct |
56 ms |
45136 KB |
Output is correct |
32 |
Correct |
1267 ms |
44376 KB |
Output is correct |
33 |
Correct |
56 ms |
44892 KB |
Output is correct |
34 |
Correct |
53 ms |
44892 KB |
Output is correct |
35 |
Correct |
27 ms |
22364 KB |
Output is correct |
36 |
Correct |
29 ms |
22364 KB |
Output is correct |
37 |
Correct |
26 ms |
22364 KB |
Output is correct |
38 |
Correct |
52 ms |
11612 KB |
Output is correct |
39 |
Correct |
51 ms |
11608 KB |
Output is correct |
40 |
Correct |
73 ms |
45400 KB |
Output is correct |
41 |
Correct |
53 ms |
11608 KB |
Output is correct |
42 |
Correct |
70 ms |
45400 KB |
Output is correct |
43 |
Correct |
74 ms |
45492 KB |
Output is correct |
44 |
Correct |
1 ms |
1624 KB |
Output is correct |
45 |
Runtime error |
258 ms |
524288 KB |
Execution killed with signal 9 |
46 |
Halted |
0 ms |
0 KB |
- |